UFTfmObjectImpl:
CEDAR
PROGRAM
IMPORTS RealFns, UFTfmReader
EXPORTS UFTfmObject
SHARES UnifiedFonts
= BEGIN
FillInMetricsObject:
PUBLIC
PROCEDURE [font: UnifiedFonts.
FONT, key: UnifiedFonts.Key] = {
[bc: font.bc, ec: font.ec] ← UFTfmReader.Range[key];
font.FontMetricProc ← FontMetricProc;
font.CharMetricProc ← CharMetricProc;
font.LigKernProc ← LigKernProc;
font.ContainsProc ← ContainsProc;
font.metricKey ← key;
};
FontMetricProc:
PROCEDURE [font: UnifiedFonts.
FONT, fontMetricCode: UnifiedFonts.FontMetricCode]
RETURNS [metric:
REAL] = {
Slant: PROC RETURNS [REAL] = {numerator, denominator: INT; [numerator, denominator] ← UFTfmReader.Slant[font.metricKey]; RETURN[RealFns.ArcTanDeg[numerator, denominator]]};
metric ←
SELECT fontMetricCode
FROM
xHeight => font.transformation.scale*UFTfmReader.Parameter[font.metricKey, xHeight],
slant => Slant[],
underlineOffset => font.transformation.scale*UFTfmReader.Depth[font.metricKey, 'g],
underlineThickness => 0.4,
ENDCASE => 0.0;
};
CharMetricProc:
PROCEDURE [font: UnifiedFonts.
FONT, characterMetricCode: UnifiedFonts.CharacterMetricCode, char:
CHAR]
RETURNS [metric:
REAL] = {
metric ←
SELECT characterMetricCode
FROM
widthX => font.transformation.scale*UFTfmReader.Width[font.metricKey, char],
widthY => 0.0,
leftExtent => 0.0,
rightExtent => font.transformation.scale*UFTfmReader.Width[font.metricKey, char],
descent => font.transformation.scale*UFTfmReader.Depth[font.metricKey, char],
ascent => font.transformation.scale*UFTfmReader.Height[font.metricKey, char],
ENDCASE => 0.0;
};
LigKernProc:
PROCEDURE [font: UnifiedFonts.
FONT, char1, char2:
CHAR]
RETURNS [UnifiedFonts.LigatureOrKern] = {
RETURN[UFTfmReader.LigKern[font.metricKey, char1, char2]];
};
ContainsProc:
PROCEDURE [font: UnifiedFonts.
FONT, char:
CHAR]
RETURNS [
BOOLEAN] = {
RETURN[UFTfmReader.Contains[font.metricKey, char]];
};
END.