sys7.1-doc-wip/Internal/Asm/fontPrivate.a

437 lines
20 KiB
Plaintext
Raw Normal View History

2019-07-27 14:37:48 +00:00
;
; File: fontPrivate.a
;
; Contains: All particular spline definitions needed for the spline package.
;
; Written by: Charlton E. Lui
;
; Copyright: © 1989-1992 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <29> 9/2/92 DTY Convert those damned incremental labels into records.
; <28> 7/9/92 DTY This file got corrupted somehow. Fix it back up from version
; <26> and redo last change.
; <27> 7/9/92 DTY #1035445: Increased partial zone size to 10K.
; <26> 7/4/92 DTY #1034875 <csd>: Define 5K size of base systems partial font
; zone here.
; <25> 5/4/92 DTY There really was a good reason for me to stick fondCache in the
; middle of SplineKey, honest! But since I dont remember what it
; is, Im moving it to the end of the structure to keep existing
; offsets the same.
; <24> 3/9/92 DTY Add macros for new selectors for InitializePartialFonts and
; InitializeDiskCache.
; <23> 1/22/92 DTY Take the synFOND field out of the synthetic strike table
; structure. Were gauranteeing unique font IDs, so this extra
; differentiation wont be necessary.
; <22> 11/15/91 DTY Remember which resource map a font was loaded from. Added the
; synFOND field to the synEntry record. (If it turns out the
; developers are looking at these records, this information will
; probably have to be moved.)
; <21> 10/11/91 DTY Building the candidate FOND list takes too long. Cache two lists
; in SplineKey.
; <20> 9/25/91 jlf Added fSplineDirectory to widthTable definition. Replaced
; glyphCount and glyphLimit with fEncodingTablePointer,
; fScriptNumber, and fLongPad in the sb_CacheHead definition.
; Added spline key globals for partial font, disk caching,
; and doublebyte support. Added KeepSplineOnDisk field to
; width table structure.
; <19> 8/22/91 JSM Clean up header.
; <18> 1/30/91 gbm sab, #38: Change the already including this file variable to
; all uppercase (for security reasons)
; <17> 1/9/91 RB (CEL/PKE/GM/DA) Added in safeCount variable to splineKey globals
; to fix the long string bug caused in stdtxmeas overflow.
; <16> 12/18/90 MR [ph] Add IsSpline macro for BassPatches.a
; <15> 10/30/90 CL (MR)Adding fs_LowestPPEM macro.
; <14> 10/22/90 CL (BKR)Adding support for minimum memory mode to band and run in
; low memory cache conditions.
; <12> 10/10/90 CL Adding sb_PreFlightFontMem selector.
; <11> 10/8/90 CL Adding loadSpline flag to the widthTable.
; <10> 10/8/90 CL Fixing up the splinekey vGrowZone variable. This accidently got
; placed over the tempWidthHand.
; <9> 10/1/90 CL Adding in memoryPatch vector for memory manager fix on the
; growzone.
; <8> 9/24/90 CL Adding the fmAscent, fmDescent, fmWidmax, fmLeading fields to
; the cache.
; <7> 9/13/90 CL Taking out unused variables in the caching records.
; Cleaned up splinekeyRec… Added in heap defines into splineKey.
; <6> 8/29/90 CL Added the cache zone to splinekey. Added mfExists flag.
; <5> 8/28/90 MR Add bitmapzone to splinekey
; <4> 8/20/90 MR Add fsWorkZone to record which zone the work handle is allocated
; in.
; <3> 7/20/90 gbm Stopped redefining all of the width table, so the assembler
; won't complain
; <2> 7/16/90 CL Adding glyph data structure. Added clean up vector in splinekey.
; <1> 6/22/90 CL first checked in
; <6+> 6/20/90 CL Used to be SplineDefines.a.
; <6> 5/29/90 CL Took out width table references to the cache handles.
; <5> 5/3/90 CL Got rid of old comments. may have added support for extra memory
; area.
; <4> 4/10/90 CL Added support for double byte codes. Worked on disk caching.
; <3> 3/20/90 CL support for tag format
; <2> 2/27/90 CL suppport for DrTexts optimizations
; <1.9> 11/14/89 CEL Adding Device left side bearing.
; <1.8> 9/15/89 CEL Added flag to turn on debugging from macsbug.
; <1.7> 8/28/89 CEL Updated splinekey to match c defines.
; <1.6> 8/14/89 CEL Added memory macros. Added in encrytion var in width table.
; Added splineKeyRec.
; <1.5> 8/1/89 CEL Conditionalized the Debug Macro. Used assembly records for
; structures that are passed between Drtext and buffer code. Added
; NewTempHandle, NewTempBuffer, NewDisposeHandle macros.
; <1.4> 6/10/89 CEL Moved Private.a QuickDraw Equates into proper QuickDraw private
; file (colorequ.a), got rid of QuickDraw nFiles dependencies and
; fixed up necessary files…
; <1.3> 6/2/89 CEL Changed translate24To32 trap address so we can worked with
; 32-bit QD once more
; <1.2> 5/26/89 CEL Integrated the new Font Scaler 1.0 into Spline Fonts
; <•1.1> 5/3/89 CEL All kinks worked out, Blasting in bass files…
; <1.0> 5/2/89 CEL Rolling in bass for the first time…
;
;——————————————————————————————————————————————————————————————————————————————————————————
BLANKS ON
STRING PASCAL
;——————————————————————————————————————————————————————————————————————————————————————————
; Spline Data Structures
;——————————————————————————————————————————————————————————————————————————————————————————
splinePreferred EQU 5
preserveGlyph EQU 4
kMinimalPartialFontZoneSize equ 10 * 1024 ; <26> A minimal partial font zone for the base system
;—————————————————————
; SplineKey Struct
;—————————————————————
; IF CHANGE in c-def
; Update this definition
;
;
splineKeyRec RECORD 0
callDebug DS.L 1 ; Set if debugging is on
vFontCache DS.L 1 ; Dispatch table for QuickDraw caching
vFontScaler DS.L 1 ; Dispatch table for QuickDraw caching
bitmapHand DS.L 1 ; Bitmap Handle - Number 5 in Font Scaler
bitmapZone DS.L 1 ; Zone the bitmapHand is allocated in <5>
cacheListHandle DS.L 1 ; List of Cache Handles
cacheHand DS.L 1 ; Handle to cache hand
cacheZone DS.L 1 ; zone the cache lives in
cachePlace DS.W 1 ; zone the cache lives in
fontCount DS.W 1 ; Set to Zero on increment each time a new cache exists
curAppZone DS.L 1 ; current application zone
sysFull DS.B 1 ; system is full
appFull DS.B 1 ; app is full
useHeap DS.B 1 ; which heap to use
mfExists DS.B 1 ; flags whether multiFinder exists
glyphID DS.W 1 ; last glyph id
is32Bit DS.B 1 ; does 32bit QD exist
squashed DS.B 1 ; are we squashing the cache
strikeID DS.W 1 ; check if still same sfnt
ptSize DS.W 1 ; Check Point Size the same
device DS.W 1 ; check Device resolution the same
face DS.W 1 ; check Face the same
trans00 DS.L 1 ; x trans
trans11 DS.L 1 ; y trans
trans10 DS.L 1 ; skew
tempWidthHand DS.L 1 ; Used temporarily to get printer widths
vGrowZone DS.L 1 ; vector for growzone patch
safeCount DS.W 1 ; safe count in case of length overflow
EXTRAWORD DS.W 1
; *******FONT SCALER MEMORY*******
fsWorkHand DS.L 1 ; work area for spline data
fsWorkZone DS.L 1 ; zone for the work handle <4>
inPtr DS.L 1 ; pointer to input struct
outPtr DS.L 1 ; pointer to info struct
inputOffset DS.L 1 ; Constant memory
infoOffset DS.L 1 ; Constant memory
globalOffset0 DS.L 1 ; Constant memory
globalOffset1 DS.L 1 ; Constant memory
globalOffset2 DS.L 1 ; Constant memory
sfntDataOffset3 DS.L 1 ; Variable size memory
sfntDataOffset4 DS.L 1 ; Variable size memory
rowArrayOffset6 DS.L 1 ; Variable size memory
columnArrayOffset7 DS.L 1 ; Variable size memory
fPartialFontzone DS.L 1 ; zone for partial font fragments
fFragmentTableCache DS.L 1 ; list of fragment tables
fLastSwapFontFamilyID DS.W 1 ; FMInput family id passed in at last SwapFont call
fDiskCacheMap DS.L 1 ; Handle to the disk cache
fResourceManagerPurgeProcedure DS.L 1 ; address of resource manager purge procedure
fInPurgeProcedure DS.B 1 ; true if currently in our purge procedure
fFontCacheExists DS.B 1 ; true if font cache exists.
lastFontMap ds.w 1 ; Resource map last font was loaded from
fondCache ds.l 2 ; Cache for candidate FOND list
splineKeySize equ * ; size for this version
ENDR
;—————————————————————
;—————————————————————
; GlyphData Struct
;—————————————————————
; IF CHANGE in c-def
; Update this definition
;
glyph RECORD 0
yMin DS.W 1 ; Y min off baseline
yMax DS.W 1 ; Y max off baseline
lsb DS.L 1 ; Left side bearing Fixed
devLSB DS.W 1 ; Device Left side bearing
adjustTop DS.W 1 ; Adjust this char from ascent
rError DS.W 1 ; set if Render error occurs
bitWidth DS.W 1 ; glyph bit width
byteWidth DS.L 1 ; row bytes of character
xMin DS.W 1 ; Save xMin and also use to calc xMax
scan DS.W 1 ; # of scan lines
wasteBytes DS.W 1 ; not needed for bitmap but needed for scan converter
glyphID DS.W 1 ; id of glyph
cacheData DS.L 1 ; Start of destination bits buffer
ENDR
;—————————————————————
;—————————————————————
; sb_CacheHead
;—————————————————————
; IF CHANGE in c-def
; Update this definition
;
cache RECORD 0
StrikeID DS.W 1 ; id of sfnt
ptSize DS.W 1 ; point size
face DS.W 1 ; style of request
newEntries DS.W 1 ; Number of new entries added
trans00 DS.L 1 ; x trans
trans11 DS.L 1 ; y trans
trans10 DS.L 1 ; skew
ascent DS.L 1 ;(fixed) Ascent of Font
descent DS.L 1 ;(fixed) Descent of Font
widMax DS.L 1 ;(fixed) Maximum Width
leading DS.L 1 ;(fixed) Leading of Font
lOverHMax DS.L 1 ;(fixed) Left Over Hang Max
rOverHMax DS.L 1 ;(fixed) Right Over Hang Max
yMax DS.L 1 ;(fixed) YMax
yMin DS.L 1 ;(fixed) YMin
height DS.W 1 ;(word) Height
filler DS.W 1 ;(word) Height
rightItalic DS.L 1 ;(fixed width italic slope)
leftItalic DS.L 1 ;(fixed width italic slope)
fmAscent DS.B 1 ; FMOutput ascent
fmDescent DS.B 1 ; FMOutput descent
fmWidmax DS.B 1 ; FMOutput widmax
fmLeading DS.B 1 ; FMOutput leading
addEntryOffset DS.L 1 ; Offset to next spot to add
bitsCached DS.B 1 ; Set if bitmaps are cached
squashed DS.B 1 ; set if the cache is squashed
familyID DS.W 1 ; Family id for international checks
fEncodingTablePointer DS.L 1 ; pointer to double byte encoding table or nil for single byte scripts
fScriptNumber DS.W 1 ; script associated with this cache
fLongPad DS.W 1 ; long align fields
glyphArray DS.L 1 ; Array of offsets starts here
ENDR
;—————————————————————
;——————————————————————————————————————————————————————————————————————————————————————————
; ERROR CODES
;——————————————————————————————————————————————————————————————————————————————————————————
BITFONT_ERR EQU $8099
NO_CACHE_ERROR EQU $00C0
;——————————————————————————————————————————————————————————————————————————————————————————
; SELECTOR MACROS
;——————————————————————————————————————————————————————————————————————————————————————————
; TRAP chummings
;—————————————————————
_SplineMgr OPWORD $A854
;—————————————————————
; Selectors
;—————————————————————
sbIsOutline EQU $0000
sbKillSomeCaches EQU $0002
sbRetrieveGlyph EQU $0004
sbFillWidthTab EQU $0005
sbSearchForCache EQU $0006
sbPreFlightFontMem EQU $0007
sbFlushFonts EQU $000C
fsLowestPPEM EQU $000e
selectInitializePartialFonts equ $000F ; <24>
selectInitializediskCache equ $0010 ; <24>
;—————————————————————
; Macros
;—————————————————————
MACRO
_sbIsOutline
IMPORT SplineMgr
MOVEQ #sbIsOutline,D0
_SplineMgr
ENDM
MACRO
_sbRetrieveGlyph
IMPORT SplineMgr
MOVEQ #sbRetrieveGlyph,D0
_SplineMgr
ENDM
MACRO
_sbKillSomeCaches
IMPORT SplineMgr
MOVEQ #sbKillSomeCaches,D0
_SplineMgr
ENDM
MACRO
_sbFillWidthTab
IMPORT SplineMgr
MOVEQ #sbFillWidthTab,D0
_SplineMgr
ENDM
MACRO
_sbResetWorkSpace
IMPORT SplineMgr
MOVEQ #sbResetWorkSpace,D0
_SplineMgr
ENDM
MACRO
_sbInitMemory
IMPORT SplineMgr
MOVEQ #sbInitMemory,D0
_SplineMgr
ENDM
MACRO
_sbSetFontState
IMPORT SplineMgr
MOVEQ #sbSetFontState,D0
_SplineMgr
ENDM
MACRO
_sbSearchForCache
IMPORT SplineMgr
MOVEQ #sbSearchForCache,D0
_SplineMgr
ENDM
MACRO
_sbPreFlightFontMem
IMPORT SplineMgr
MOVEQ #sbPreFlightFontMem,D0
_SplineMgr
ENDM
MACRO
_fsLowestPPEM
IMPORT SplineMgr
MOVEQ #fsLowestPPEM,D0
_SplineMgr
ENDM
MACRO
_GetStyleBufHand
IMPORT GetStyleBufHand
JSR GetStyleBufHand
ENDM
MACRO
_sbFlushFonts
IMPORT SplineMgr
MOVEQ #sbFlushFonts,D0
_SplineMgr
ENDM
Macro ; <24>
_InitializePartialFonts ; <24>
moveq #selectInitializePartialFonts,d0 ; <24>
_SplineMgr ; <24>
EndM ; <24>
Macro ; <24>
_InitializeDiskCache ; <24>
moveq #selectInitializeDiskCache,d0 ; <24>
_SplineMgr ; <24>
EndM ; <24>
;——————————————————————————————————————————————————————————————————————————————————————————
; SPLINE WIDTH TABLE
;——————————————————————————————————————————————————————————————————————————————————————————
;WidTabData EQU 0 ;256 fixed point widths
;WidTabFont EQU 1024 ;(long) font handle used to generate this width table
;WidthSExtra EQU WidTabFont+4 ;(long) fixed point space extra used for this table
;WidthStyle EQU WidthSExtra+4 ;(long) fixed point extra due to style, used for this table
;WidthFID EQU WidthStyle+4 ;(word) font family ID for this table
;WidthFSize EQU WidthFID+2 ;(word) font size request that generated this table
;WidthFace EQU WidthFSize+2 ;(word) face request that generated this table
;WidthDevice EQU WidthFace+2 ;(word) device requested
WidthScales EQU 1044 ; WidthDevice+2 ;(8 bytes) scale factors requested on input
;WidthAFID EQU WidthScales+8 ;(word) actual font family ID for this table
;WidthFHand EQU WidthAFID+2 ;(long) font family handle for this table
;WidthUsedFam EQU WidthFHand+4 ;(boolean) whether we used fixed point family widths
;WidthAFace EQU WidthUsedFam+1 ;(byte) actual face produced (may differ for styled fonts)
;WidthVOutput EQU WidthAFace+1 ;(word) vertical scale output value
;WidthHOutput EQU WidthVOutput+2 ;(word) horizontal scale output value
;WidthVFactor EQU WidthHOutput+2 ;(word) vertical scale output value
;WidthHFactor EQU WidthVFactor+2 ;(word) horizontal scale output value
;WidthASize EQU WidthHFactor+2 ;(word) actual size of font strike used
WidthNFNT EQU 1070 ; WidthASize+2 ;(word) high bit set if strike used is NFNT
WidthStrikeID EQU WidthNFNT+2 ;(word) FONT, NFNT or SFNT resource ID
WidthHint EQU WidthStrikeID+2 ;(word) index to last used entry in color strike table (unimplemented)
WidthDevRes EQU WidthHint+2 ;(word) Output Device Resolution
WidthIsSpline EQU WidthDevRes+2 ;(Boolean) non zero means spline exists
WidthNotFast EQU WidthIsSpline+1 ;(Boolean) set for the not fast case
WidthBadFont EQU WidthNotFast+1 ;(Boolean) Corrupted font flag
WidthLoadSpline EQU WidthBadFont+1 ;(Boolean) load a spline?
WidthFREEBYTE EQU WidthLoadSpline+1 ;(Boolean)
WidthTrans00 EQU WidthFREEBYTE+2 ; x trans
WidthTrans11 EQU WidthTrans00+4 ; y trans
WidthTrans10 EQU WidthTrans11+4 ; skew
KeepSplineOnDisk EQU WidthTrans10+4 ; (word) non-zero means don't load the spline into memory.
WidTabSize EQU KeepSplineOnDisk+2 ;total size of a width table.
fSplineDirectory EQU WidTabSize ;copy of sfnt directory is appended to end of widthtable
;——————————————————————————————————————————————————————————————————————————————————————————
;——————————————————————————————————————————————————————————————————————————————————————————
FoutCurStyle EQU $9A9 ;post the current style used here.
NumTables EQU 12
FMSwapTrap EQU $101 ;the FMSwapFont trap number for _GetTrapAddr
WidListSize EQU NumTables*4
; FOND format definition
FontFamilyRecord Record 0
FONDFlags ds.w 1 ; Flags word for family
FONDFamID ds.w 1 ; Family ID number
FONDFirst ds.w 1 ; First character in font
FONDLast ds.w 1 ; Last character in font
FONDAscent ds.w 1 ; Maximum ascent expressed for 1 pt.
FONDDescent ds.w 1 ; Maximum descent expressed for 1 pt.
FONDLeading ds.w 1 ; Maximum leading expressed for 1 pt.
FONDWidMax ds.w 1 ; Maximum width expressed for 1 pt.
FONDWTabOff ds.l 1 ; Offset to width table
FONDKernOff ds.l 1 ; Offset to kerning table
FONDStylOff ds.l 1 ; Offset to style mapping table
FONDProperty ds.w 12 ; Style property information
FONDAssoc equ * ; Start of font association table
EndR
FAssocSiz EQU 6 ;size of a font association table entry.
; Synthetic strike table structure
; for each entry:
SyntheticStrikeTable Record 0
synStrike ds.l 1 ; Handle to sythesized strike
synNFNT ds.w 1 ; High bit set if strike is 'NFNT'
synID ds.w 1 ; Resource ID of base 'NFNT' or 'FONT'
synFGColor ds.b 6 ; User requested foreground color
synBKColor ds.b 6 ; User requested background color
synEntry equ * ; Size of synthetic strike table entry
EndR