Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[makeotfexe] support OS/2.sFamilyClass in feature files #1192

Merged
merged 6 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ cov.xml
# ignore the compiled programs
c/build_all/*
!c/build_all/this_folder_intentionally_left_empty
# ANTLR binaries
**/hotpccts/pccts/bin/**

# ignore the temp build directories and files
*.o
Expand Down
2 changes: 1 addition & 1 deletion c/makeotf/makeotf_lib/api/hotconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This software is licensed as OpenSource, under the Apache License, Version 2.0.
extern "C" {
#endif

#define HOT_VERSION 0x010073 /* Library version (1.0.115) */
#define HOT_VERSION 0x010074 /* Library version (1.0.116) */
/* Major, minor, build = (HOT_VERSION >> 16) & 0xff, (HOT_VERSION >> 8) & 0xff, HOT_VERSION & 0xff) */
/* Warning: this string is now part of heuristic used by CoolType to identify the
first round of CoolType fonts which had the backtrack sequence of a chaining
Expand Down
4 changes: 4 additions & 0 deletions c/makeotf/makeotf_lib/build/hotpccts/featgram.g
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ int sawCVParams = FALSE;
#token K_WeightClass "WeightClass"
#token K_WidthClass "WidthClass"
#token K_Vendor "Vendor"
#token K_FamilyClass "FamilyClass"

#token K_STAT "STAT" /* Added tag to list in zzcr_attr() */
#token K_ElidedFallbackName "ElidedFallbackName"
Expand Down Expand Up @@ -1960,6 +1961,9 @@ table_OS_2
K_UpperOpticalPointSize numUInt16>[valUInt16]
<<OS_2UpperOpticalPointSize(g, valUInt16);>>
|
K_FamilyClass numUInt16Ext>[valUInt16]
<<OS_2FamilyClass(g, valUInt16);>>
|
(K_Vendor T_STRING)
<<addVendorString(g);>>
|
Expand Down
86 changes: 46 additions & 40 deletions c/makeotf/makeotf_lib/source/hotconv/OS_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@
#define VEND_ID_SIZE 4

typedef struct {
unsigned short version;
short xAvgCharWidth;
unsigned short usWeightClass;
uint16_t version;
int16_t xAvgCharWidth;
uint16_t usWeightClass;
#define FWEIGHT_NORMAL 400
unsigned short usWidthClass;
uint16_t usWidthClass;
#define FWIDTH_NORMAL 5
unsigned short fsType; /* Embedding permissions */
uint16_t fsType; /* Embedding permissions */
#define EMBED_NONE (1 << 1)
#define EMBED_PRINT_AND_VIEW (1 << 2)
#define EMBED_EDITABLE (1 << 3)
short ySubscriptXSize;
short ySubscriptYSize;
short ySubscriptXOffset;
short ySubscriptYOffset;
short ySuperscriptXSize;
short ySuperscriptYSize;
short ySuperscriptXOffset;
short ySuperscriptYOffset;
short yStrikeoutSize;
short yStrikeoutPosition;
short sFamilyClass;
int16_t ySubscriptXSize;
int16_t ySubscriptYSize;
int16_t ySubscriptXOffset;
int16_t ySubscriptYOffset;
int16_t ySuperscriptXSize;
int16_t ySuperscriptYSize;
int16_t ySuperscriptXOffset;
int16_t ySuperscriptYOffset;
int16_t yStrikeoutSize;
int16_t yStrikeoutPosition;
uint16_t sFamilyClass; /* spec defines this as signed */
#define CLASS_NONE 0
char panose[PANOSE_SIZE];
#define PANOSE_ANY 0 /* [any] */
Expand All @@ -61,28 +61,28 @@ typedef struct {
uint32_t ulUnicodeRange3;
uint32_t ulUnicodeRange4;
char achVendId[VEND_ID_SIZE];
unsigned short fsSelection;
uint16_t fsSelection;
#define SEL_ITALIC (1 << 0)
#define SEL_BOLD (1 << 5)
#define SEL_REGULAR (1 << 6)
#define SEL_RESPECT_STYPO (1 << 7)

unsigned short usFirstCharIndex;
unsigned short usLastCharIndex;
short sTypoAscender;
short sTypoDescender;
short sTypoLineGap;
unsigned short usWinAscent;
unsigned short usWinDescent;
uint16_t usFirstCharIndex;
uint16_t usLastCharIndex;
int16_t sTypoAscender;
int16_t sTypoDescender;
int16_t sTypoLineGap;
uint16_t usWinAscent;
uint16_t usWinDescent;
uint32_t ulCodePageRange1; /* Version 1 */
uint32_t ulCodePageRange2; /* Version 1 */
short sXHeight; /* Version 2 */
short sCapHeight; /* Version 2 */
unsigned short usDefaultChar; /* Version 2 */
unsigned short usBreakChar; /* Version 2 */
unsigned short usMaxContext; /* Version 2 */
unsigned short usLowerOpticalPointSize; /* Version 5 */
unsigned short usUpperOpticalPointSize; /* Version 5 */
int16_t sXHeight; /* Version 2 */
int16_t sCapHeight; /* Version 2 */
uint16_t usDefaultChar; /* Version 2 */
uint16_t usBreakChar; /* Version 2 */
uint16_t usMaxContext; /* Version 2 */
uint16_t usLowerOpticalPointSize; /* Version 5 */
uint16_t usUpperOpticalPointSize; /* Version 5 */
} OS_2Tbl;

/* --------------------------- Context Definition -------------------------- */
Expand Down Expand Up @@ -122,6 +122,7 @@ void OS_2New(hotCtx g) {
h->tbl.usMaxContext = 0;
h->tbl.usLowerOpticalPointSize = 0;
h->tbl.usUpperOpticalPointSize = 0;
h->tbl.sFamilyClass = CLASS_NONE;

/* Link contexts */
h->g = g;
Expand All @@ -132,7 +133,7 @@ void OS_2New(hotCtx g) {
static void setClasses(hotCtx g, OS_2Ctx h) {
typedef struct {
char *string;
unsigned short value;
uint16_t value;
} Match;
static Match weight[] = {
{"thin", 250},
Expand Down Expand Up @@ -345,7 +346,7 @@ int OS_2Fill(hotCtx g) {
h->tbl.yStrikeoutSize = font->win.StrikeOutSize;
h->tbl.yStrikeoutPosition = font->win.StrikeOutPosition;

h->tbl.sFamilyClass = CLASS_NONE; /* No classification */
// h->tbl.sFamilyClass = CLASS_NONE; /* No classification */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this commented-out code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh! Thanks for catching this. Fixed in a41e3f9

if (!h->seen[kPanose]) {
setPanose(g, h);
}
Expand Down Expand Up @@ -482,8 +483,8 @@ void OS_2SetCodePageRanges(hotCtx g,
}

void OS_2SetCharIndexRange(hotCtx g,
unsigned short usFirstCharIndex,
unsigned short usLastCharIndex) {
uint16_t usFirstCharIndex,
uint16_t usLastCharIndex) {
OS_2Ctx h = g->ctx.OS_2;
h->tbl.usFirstCharIndex = usFirstCharIndex;
h->tbl.usLastCharIndex = usLastCharIndex;
Expand All @@ -499,35 +500,40 @@ void OS_2SetMaxContext(hotCtx g, unsigned maxContext) {
}
}

void OS_2LowerOpticalPointSize(hotCtx g, unsigned short opSize) {
void OS_2LowerOpticalPointSize(hotCtx g, uint16_t opSize) {
OS_2Ctx h = g->ctx.OS_2;
h->tbl.usLowerOpticalPointSize = opSize;
}

void OS_2UpperOpticalPointSize(hotCtx g, unsigned short opSize) {
void OS_2UpperOpticalPointSize(hotCtx g, uint16_t opSize) {
OS_2Ctx h = g->ctx.OS_2;
h->tbl.usUpperOpticalPointSize = opSize;
}

void OS_2FamilyClass(hotCtx g, uint16_t familyClass) {
OS_2Ctx h = g->ctx.OS_2;
h->tbl.sFamilyClass = familyClass;
}

void OS_2SetPanose(hotCtx g, char *panose) {
OS_2Ctx h = g->ctx.OS_2;
memcpy(h->tbl.panose, panose, PANOSE_SIZE);
h->seen[kPanose] = 1;
}

void OS_2SetFSType(hotCtx g, unsigned short fsType) {
void OS_2SetFSType(hotCtx g, uint16_t fsType) {
OS_2Ctx h = g->ctx.OS_2;
h->tbl.fsType = fsType;
h->seen[kFSType] = 1;
}

void OS_2SetWeightClass(hotCtx g, unsigned short weightClass) {
void OS_2SetWeightClass(hotCtx g, uint16_t weightClass) {
OS_2Ctx h = g->ctx.OS_2;
h->tbl.usWeightClass = weightClass;
h->seen[kWeightClass] = 1;
}

void OS_2SetWidthClass(hotCtx g, unsigned short widthClass) {
void OS_2SetWidthClass(hotCtx g, uint16_t widthClass) {
OS_2Ctx h = g->ctx.OS_2;
h->tbl.usWidthClass = widthClass;
h->seen[kWidthClass] = 1;
Expand Down
15 changes: 8 additions & 7 deletions c/makeotf/makeotf_lib/source/hotconv/OS_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ void OS_2SetCodePageRanges(hotCtx g,
uint32_t lCodePageRange1,
uint32_t ulCodePageRange2);
void OS_2SetCharIndexRange(hotCtx g,
unsigned short usFirstCharIndex,
unsigned short usLastCharIndex);
uint16_t usFirstCharIndex,
uint16_t usLastCharIndex);
void OS_2SetMaxContext(hotCtx g, unsigned maxContext);
void OS_2SetPanose(hotCtx g, char *panose);
void OS_2SetFSType(hotCtx g, unsigned short fsType);
void OS_2SetWeightClass(hotCtx g, unsigned short weightClass);
void OS_2SetWidthClass(hotCtx g, unsigned short widthClass);
void OS_2LowerOpticalPointSize(hotCtx g, unsigned short opSize);
void OS_2UpperOpticalPointSize(hotCtx g, unsigned short opSize);
void OS_2SetFSType(hotCtx g, uint16_t fsType);
void OS_2SetWeightClass(hotCtx g, uint16_t weightClass);
void OS_2SetWidthClass(hotCtx g, uint16_t widthClass);
void OS_2LowerOpticalPointSize(hotCtx g, uint16_t opSize);
void OS_2UpperOpticalPointSize(hotCtx g, uint16_t opSize);
void OS_2FamilyClass(hotCtx g, uint16_t familyClass);

#endif /* HOTCONV_OS_2_H */
Loading