Skip to content

Commit

Permalink
[lib] Introduced Offset16 and Offset32 data types
Browse files Browse the repository at this point in the history
  • Loading branch information
mta452 committed Sep 10, 2019
1 parent 54cbf37 commit be81738
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
6 changes: 4 additions & 2 deletions Source/Data.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2018 Muhammad Tayyab Akram
* Copyright (C) 2015-2019 Muhammad Tayyab Akram
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,9 @@

#include "SFBase.h"

typedef SFUInt16 SFOffset;
typedef SFUInt16 Offset16;
typedef SFUInt32 Offset32;

typedef const SFUInt8 * Data;

#define Data_UInt8(data, offset) (data)[offset]
Expand Down
2 changes: 1 addition & 1 deletion Source/GlyphManipulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ static SFBoolean ApplyRuleSetTable(TextProcessorRef textProcessor,

/* Match each rule sequentially as they are ordered by preference. */
for (ruleIndex = 0; ruleIndex < ruleCount; ruleIndex++) {
SFOffset ruleOffset = RuleSet_RuleOffset(ruleSet, ruleIndex);
Offset16 ruleOffset = RuleSet_RuleOffset(ruleSet, ruleIndex);

if (ruleOffset) {
Data rule = Data_Subdata(ruleSet, ruleOffset);
Expand Down
24 changes: 12 additions & 12 deletions Source/GlyphPositioning.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void ApplyValueRecord(TextProcessorRef textProcessor, Data parentTable,
Data valueRecord, SFUInt16 valueFormat, SFUInteger inputIndex)
{
SFAlbumRef album = textProcessor->_album;
SFOffset valueOffset = 0;
Offset16 valueOffset = 0;

if (ValueFormat_XPlacement(valueFormat)) {
SFInt16 adjustment = Data_Int16(valueRecord, valueOffset);
Expand Down Expand Up @@ -96,7 +96,7 @@ static void ApplyValueRecord(TextProcessorRef textProcessor, Data parentTable,
}

if (ValueFormat_XPlaDevice(valueFormat)) {
SFOffset deviceOffset = Data_UInt16(valueRecord, valueOffset);
Offset16 deviceOffset = Data_UInt16(valueRecord, valueOffset);

if (deviceOffset) {
Data deviceTable = Data_Subdata(parentTable, deviceOffset);
Expand All @@ -110,7 +110,7 @@ static void ApplyValueRecord(TextProcessorRef textProcessor, Data parentTable,
}

if (ValueFormat_YPlaDevice(valueFormat)) {
SFOffset deviceOffset = Data_UInt16(valueRecord, valueOffset);
Offset16 deviceOffset = Data_UInt16(valueRecord, valueOffset);

if (deviceOffset) {
Data deviceTable = Data_Subdata(parentTable, deviceOffset);
Expand All @@ -124,7 +124,7 @@ static void ApplyValueRecord(TextProcessorRef textProcessor, Data parentTable,
}

if (ValueFormat_XAdvDevice(valueFormat)) {
SFOffset deviceOffset = Data_UInt16(valueRecord, valueOffset);
Offset16 deviceOffset = Data_UInt16(valueRecord, valueOffset);

switch (textProcessor->_textDirection) {
case SFTextDirectionLeftToRight:
Expand Down Expand Up @@ -380,8 +380,8 @@ static SFPoint ConvertAnchorToPoint(TextProcessorRef textProcessor, Data anchor)
}

case 3: {
SFOffset xDeviceOffset = AnchorF3_XDeviceOffset(anchor);
SFOffset yDeviceOffset = AnchorF3_YDeviceOffset(anchor);
Offset16 xDeviceOffset = AnchorF3_XDeviceOffset(anchor);
Offset16 yDeviceOffset = AnchorF3_YDeviceOffset(anchor);

point.x = AnchorF3_XCoordinate(anchor);
point.y = AnchorF3_YCoordinate(anchor);
Expand Down Expand Up @@ -418,8 +418,8 @@ static void SearchCursiveAnchors(Data cursivePos, SFGlyphID glyph,

if (entryExitIndex < entryExitCount) {
Data entryExitRecord = CursivePos_EntryExitRecord(cursivePos, entryExitIndex);
SFOffset exitAnchorOffset = EntryExitRecord_ExitAnchorOffset(entryExitRecord);
SFOffset entryAnchorOffset = EntryExitRecord_EntryAnchorOffset(entryExitRecord);
Offset16 exitAnchorOffset = EntryExitRecord_ExitAnchorOffset(entryExitRecord);
Offset16 entryAnchorOffset = EntryExitRecord_EntryAnchorOffset(entryExitRecord);

if (refExitAnchor && exitAnchorOffset) {
*refExitAnchor = Data_Subdata(cursivePos, exitAnchorOffset);
Expand Down Expand Up @@ -568,7 +568,7 @@ static Data GetMarkArrayFromAnchorTable(Data markArray, SFUInteger markIndex, SF
if (markIndex < markCount) {
Data markRecord = MarkArray_MarkRecord(markArray, markIndex);
SFUInt16 classValue = MarkRecord_Class(markRecord);
SFOffset anchorOffset = MarkRecord_MarkAnchorOffset(markRecord);
Offset16 anchorOffset = MarkRecord_MarkAnchorOffset(markRecord);
Data markAnchor = Data_Subdata(markArray, anchorOffset);

*outClass = classValue;
Expand Down Expand Up @@ -651,7 +651,7 @@ static SFBoolean ApplyMarkToBaseArrays(TextProcessorRef textProcessor, Data mark
/* Validate base index. */
if (baseIndex < baseCount) {
Data baseRecord = BaseArray_BaseRecord(baseArray, baseIndex, classCount);
SFOffset anchorOffset = BaseArray_BaseAnchorOffset(baseRecord, classValue);
Offset16 anchorOffset = BaseArray_BaseAnchorOffset(baseRecord, classValue);
Data baseAnchor = Data_Subdata(baseArray, anchorOffset);
SFPoint markPoint;
SFPoint basePoint;
Expand Down Expand Up @@ -749,7 +749,7 @@ static SFBoolean ApplyMarkToLigArrays(TextProcessorRef textProcessor, Data markL
Data ligAttach = LigatureArray_LigatureAttachTable(ligArray, ligIndex);
SFUInteger compCount = LigatureAttach_ComponentCount(ligAttach);
Data compRecord;
SFOffset anchorOffset;
Offset16 anchorOffset;
Data ligAnchor;
SFPoint markPoint;
SFPoint ligPoint;
Expand Down Expand Up @@ -850,7 +850,7 @@ static SFBoolean ApplyMarkToMarkArrays(TextProcessorRef textProcessor, Data mark
/* Validate mark 2 index. */
if (mark2Index < mark2Count) {
Data mark2Record = Mark2Array_Mark2Record(mark2Array, mark2Index, classCount);
SFOffset anchorOffset = Mark2Record_Mark2AnchorOffset(mark2Record, classValue);
Offset16 anchorOffset = Mark2Record_Mark2AnchorOffset(mark2Record, classValue);
Data mark2Anchor = Data_Subdata(mark2Array, anchorOffset);
SFPoint mark1Point;
SFPoint mark2Point;
Expand Down
14 changes: 7 additions & 7 deletions Source/Tables/OpenType.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SF_INTERNAL Data SearchScriptTable(Data scriptListTable, SFTag scriptTag)
for (index = 0; index < scriptCount; index++) {
Data scriptRecord = ScriptList_ScriptRecord(scriptListTable, index);
SFTag scriptRecTag = ScriptRecord_ScriptTag(scriptRecord);
SFOffset scriptOffset;
Offset16 scriptOffset;

if (scriptRecTag == scriptTag) {
scriptOffset = ScriptRecord_ScriptOffset(scriptRecord);
Expand All @@ -51,7 +51,7 @@ SF_INTERNAL Data SearchLangSysTable(Data scriptTable, SFTag languageTag)
Data langSysTable = NULL;

if (languageTag == SFTagMake('d', 'f', 'l', 't')) {
SFOffset langSysOffset = Script_DefaultLangSysOffset(scriptTable);
Offset16 langSysOffset = Script_DefaultLangSysOffset(scriptTable);

if (langSysOffset) {
langSysTable = Data_Subdata(scriptTable, langSysOffset);
Expand All @@ -63,7 +63,7 @@ SF_INTERNAL Data SearchLangSysTable(Data scriptTable, SFTag languageTag)
for (index = 0; index < langSysCount; index++) {
Data langSysRecord = Script_LangSysRecord(scriptTable, index);
SFTag langSysTag = LangSysRecord_LangSysTag(langSysRecord);
SFOffset langSysOffset;
Offset16 langSysOffset;

if (langSysTag == languageTag) {
langSysOffset = LangSysRecord_LangSysOffset(langSysRecord);
Expand All @@ -88,7 +88,7 @@ SF_INTERNAL Data SearchDefaultFeatureTable(Data langSysTable,
SFTag recordTag = FeatureRecord_FeatureTag(featureRecord);

if (recordTag == featureTag) {
SFOffset featureOffset = FeatureRecord_FeatureOffset(featureRecord);
Offset16 featureOffset = FeatureRecord_FeatureOffset(featureRecord);
Data featureTable = Data_Subdata(featureListTable, featureOffset);

if (featureIndex) {
Expand Down Expand Up @@ -345,11 +345,11 @@ SF_INTERNAL Data SearchFeatureSubstitutionTable(Data featureVarsTable,

for (recordIndex = 0; recordIndex < recordCount; recordIndex++) {
Data varRecord = FeatureVars_FeatureVarRecord(featureVarsTable, recordIndex);
SFUInt32 condSetOffset = FeatureVarRecord_ConditionSetOffset(varRecord);
Offset32 condSetOffset = FeatureVarRecord_ConditionSetOffset(varRecord);
Data condSetTable = Data_Subdata(featureVarsTable, condSetOffset);

if (MatchConditionSet(condSetTable, coordArray, coordCount)) {
SFUInt32 featureSubstOffset = FeatureVarRecord_FeatureSubstOffset(varRecord);
Offset32 featureSubstOffset = FeatureVarRecord_FeatureSubstOffset(varRecord);
return Data_Subdata(featureVarsTable, featureSubstOffset);
}
}
Expand All @@ -367,7 +367,7 @@ SF_INTERNAL Data SearchAlternateFeatureTable(Data featureSubstTable, SFUInt16 fe
SFUInt16 recFeatureIndex = FeatureSubstRecord_FeatureIndex(substRec);

if (recFeatureIndex == featureIndex) {
SFUInt32 altFeatureOffset = FeatureSubstRecord_AltFeatureOffset(substRec);
Offset32 altFeatureOffset = FeatureSubstRecord_AltFeatureOffset(substRec);
return Data_Subdata(featureSubstTable, altFeatureOffset);
}

Expand Down

0 comments on commit be81738

Please sign in to comment.