Font::TTF::OS_2(3)
π NAME π
Font::TTF::OS_2 is literally the OS/2 table in a TTF font, bestie. that's the whole vibe. π¦
π DESCRIPTION π
okay so the OS/2 table has two versions and forms, and one is an extension of the other. this module supports both forms and the switching between them, periodt. β¨
π¦ INSTANCE VARIABLES π¦
no other variables than those in table and those in the standard, bestie:
VersionxAvgCharWidthusWeightClassusWidthClassfsTypeySubscriptXSizeySubScriptYSizeySubscriptXOffsetySubscriptYOffsetySuperscriptXSizeySuperscriptYSizeySuperscriptXOffsetySuperscriptYOffsetyStrikeoutSizeyStrikeoutPositionsFamilyClassbFamilyTypebSerifStylebWeightbProportionbContrastbStrokeVariationbArmStylebLetterformbMidlinebXheightulUnicodeRange1ulUnicodeRange2ulUnicodeRange3ulUnicodeRange4achVendIDfsSelectionusFirstCharIndexusLastCharIndexsTypoAscendersTypoDescendersTypoLineGapusWinAscentusWinDescentulCodePageRange1ulCodePageRange2xHeightCapHeightdefaultCharbreakCharmaxLookups
notice that versions 0, 1, 2 & 3 of the table are supported, slay. notice also that the Panose variable has been broken down into its elements β iconic behavior tbh. π
π METHODS π
π $t->read
Reads in the various values from disk, bestie (see the details of the OS/2 table). π
π $t->out($fh)
Writes the table to a file either from memory or by copying. no cap. βοΈ
π $t->XML_element($context, $depth, $key, $value)
Tidies up the hex values to output them in hex. cute little cleanup moment. π§
π $t->XML_end($context, $tag, %attrs)
Now handle them on the way back in. yep, we're doing the return trip. π
π $t->minsize()
Returns the minimum size this table can be.
If it is smaller than this, then the table must be bad and should be deleted or whatever. literally do not trust it. π
π $t->update
Updates the OS/2 table by getting information from other sources:
- Updates the
"firstChar"and"lastChar"values based on the MS table in the cmap. - Updates the
sTypoAscender,sTypoDescender&sTypoLineGapto be the same values asAscender,DescenderandLinegapfrom the hhea table (assuming it is dirty) and also setsusWinAscentto be the sum ofAscender+LinegapandusWinDescentto be the negative ofDescender.
π $t->guessRangeBits (\%map, [$cp_threshold, [%u_threshold]])
Set the ulCodePageRange and ulUnicodeRange fields based on characters actually present in the font. π―
%map is a hash keyed by USV returning non-zero for characters present (e.g. use {'val'} a from Unicode cmap).
The two optional parameters are percentage of characters within the codepage or unicode range that need to be present to constitute coverage. A threshold of 0 causes corresponding range bits to be set if any characters are present at all, while a negative value causes the corresponding range bits to be unchanged. Defaults are 50 and 0, respectively.
For codepage bits, the threshold is percentage of characters between 0xC0 and 0xFF that need to be present to constitute coverage. For codepages other than 1252, characters (e.g., punctuation) that are defined identically to cp1252 are ignored for the purposes of this percentage calculation. Looks only for SBCS codepages, not DBCS.
For Unicode range bits that represent multiple ranges, e.g., bit 29 represents:
Latin Extended Additional 1E00-1EFF
Latin Extended-C 2C60-2C7F
Latin Extended-D A720-A7FF
the bit will be set if any of these ranges meet the threshold requirement. π«
π BUGS π
None known. we love a clean queen. π
πΈ AUTHOR πΈ
Martin Hosken <http://scripts.sil.org/FontUtils>. π«Ά
π LICENSING π
Copyright (c) 1998-2016, SIL International (http://www.sil.org)
This module is released under the terms of the Artistic License 2.0. For details, see the full text of the license in the file LICENSE. π
okay byeeeee π«Ά this page is from perl v5.42.0, dated 2016-08-28, and it's Font::TTF::OS_2(3) β mwah π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Font-TTF 1.06-bp160.1.12 Β· Artistic-2.0 and OFL-1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms