Changeset 459


Ignore:
Timestamp:
02/15/09 05:24:43 (4 years ago)
Author:
tal
Message:
Added support for GDEF LigCaretList.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • packages/compositor/trunk/Lib/compositor/tables.py

    r240 r459  
    2222from featureList import FeatureList 
    2323from lookupList import GSUBLookupList, GPOSLookupList 
     24from subTablesBase import Coverage 
    2425from classDefinitionTables import MarkAttachClassDef, GlyphClassDef 
    2526from textUtilities import isWordBreakBefore, isWordBreakAfter 
     
    359360        self.GlyphClassDef = None 
    360361        self.MarkAttachClassDef = None 
     362        self.LigCaretList = None 
    361363 
    362364    def loadFromFontTools(self, table): 
    363365        table = table.table 
    364         self.GlyphClassDef = GlyphClassDef().loadFromFontTools(table.GlyphClassDef) 
     366        if table.GlyphClassDef is not None: 
     367            self.GlyphClassDef = GlyphClassDef().loadFromFontTools(table.GlyphClassDef) 
    365368        if table.AttachList is not None: 
    366369            raise NotImplementedError("Need GDEF sample with AttachList") 
    367370        if table.LigCaretList is not None: 
    368             raise NotImplementedError("Need GDEF sample with LigCaretList") 
    369         if table.MarkAttachClassDef is None: 
    370             self.MarkAttachClassDef = None 
    371         else: 
     371            self.LigCaretList = LigCaretList().loadFromFontTools(table.LigCaretList) 
     372        if table.MarkAttachClassDef is not None: 
    372373            self.MarkAttachClassDef = MarkAttachClassDef().loadFromFontTools(table.MarkAttachClassDef) 
    373374        return self 
     375 
     376 
     377class LigCaretList(object): 
     378 
     379    """ 
     380    Deviation from spec: 
     381    - LigGlyphCount attribute is not implemented. 
     382    """ 
     383 
     384    __slots__ = ["LigGlyph", "Coverage"] 
     385 
     386    def __init__(self): 
     387        self.LigGlyph = [] 
     388        self.Coverage = None 
     389 
     390    def loadFromFontTools(self, table): 
     391        self.Coverage = Coverage().loadFromFontTools(table.Coverage) 
     392        for ligGlyph in table.LigGlyph: 
     393            ligGlyph = LigGlyph().loadFromFontTools(ligGlyph) 
     394            self.LigGlyph.append(ligGlyph) 
     395        return self 
     396 
     397 
     398class LigGlyph(object): 
     399 
     400    """ 
     401    Deviation from spec: 
     402    - CaretValueCount attribute is not implemented. 
     403    """ 
     404 
     405    __slots__ = ["CaretValue"] 
     406 
     407    def __init__(self): 
     408        self.CaretValue = [] 
     409 
     410    def loadFromFontTools(self, ligGlyph): 
     411        for caretValue in ligGlyph.CaretValue: 
     412            format = caretValue.Format 
     413            if format == 1: 
     414                caretValue = CaretValueFormat1().loadFromFontTools(caretValue) 
     415            elif format == 2: 
     416                caretValue = CaretValueFormat2().loadFromFontTools(caretValue) 
     417            else: 
     418                caretValue = CaretValueFormat3().loadFromFontTools(caretValue) 
     419            self.CaretValue.append(caretValue) 
     420        return self 
     421 
     422 
     423class CaretValueFormat1(object): 
     424 
     425    __slots__ = ["CaretValueFormat", "Coordinate"] 
     426 
     427    def __init__(self): 
     428        self.CaretValueFormat = 1 
     429        self.Coordinate = None 
     430 
     431    def loadFromFontTools(self, caretValue): 
     432        self.Coordinate = caretValue.Coordinate 
     433        return self 
     434 
     435 
     436class CaretValueFormat2(object): 
     437 
     438    __slots__ = ["CaretValueFormat", "CaretValuePoint"] 
     439 
     440    def __init__(self): 
     441        self.CaretValueFormat = 2 
     442        self.CaretValuePoint = None 
     443 
     444    def loadFromFontTools(self, caretValue): 
     445        self.CaretValuePoint = caretValue.CaretValuePoint 
     446        return self 
     447 
     448 
     449class CaretValueFormat3(CaretValueFormat1): 
     450 
     451    """ 
     452    Deviation from spec: 
     453    - DeviceTable attribute is not implemented. 
     454    """ 
     455 
     456    __slots__ = ["CaretValueFormat", "Coordinate", "DeviceTable"] 
     457 
     458    def __init__(self): 
     459        super(CaretValueFormat3, self).__init__() 
     460        self.DeviceTable = None 
     461 
Note: See TracChangeset for help on using the changeset viewer.