...

Source file src/github.com/golang/freetype/truetype/opcodes.go

Documentation: github.com/golang/freetype/truetype

     1  // Copyright 2012 The Freetype-Go Authors. All rights reserved.
     2  // Use of this source code is governed by your choice of either the
     3  // FreeType License or the GNU General Public License version 2 (or
     4  // any later version), both of which can be found in the LICENSE file.
     5  
     6  package truetype
     7  
     8  // The Truetype opcodes are summarized at
     9  // https://developer.apple.com/fonts/TTRefMan/RM07/appendixA.html
    10  
    11  const (
    12  	opSVTCA0    = 0x00 // Set freedom and projection Vectors To Coordinate Axis
    13  	opSVTCA1    = 0x01 // .
    14  	opSPVTCA0   = 0x02 // Set Projection Vector To Coordinate Axis
    15  	opSPVTCA1   = 0x03 // .
    16  	opSFVTCA0   = 0x04 // Set Freedom Vector to Coordinate Axis
    17  	opSFVTCA1   = 0x05 // .
    18  	opSPVTL0    = 0x06 // Set Projection Vector To Line
    19  	opSPVTL1    = 0x07 // .
    20  	opSFVTL0    = 0x08 // Set Freedom Vector To Line
    21  	opSFVTL1    = 0x09 // .
    22  	opSPVFS     = 0x0a // Set Projection Vector From Stack
    23  	opSFVFS     = 0x0b // Set Freedom Vector From Stack
    24  	opGPV       = 0x0c // Get Projection Vector
    25  	opGFV       = 0x0d // Get Freedom Vector
    26  	opSFVTPV    = 0x0e // Set Freedom Vector To Projection Vector
    27  	opISECT     = 0x0f // moves point p to the InterSECTion of two lines
    28  	opSRP0      = 0x10 // Set Reference Point 0
    29  	opSRP1      = 0x11 // Set Reference Point 1
    30  	opSRP2      = 0x12 // Set Reference Point 2
    31  	opSZP0      = 0x13 // Set Zone Pointer 0
    32  	opSZP1      = 0x14 // Set Zone Pointer 1
    33  	opSZP2      = 0x15 // Set Zone Pointer 2
    34  	opSZPS      = 0x16 // Set Zone PointerS
    35  	opSLOOP     = 0x17 // Set LOOP variable
    36  	opRTG       = 0x18 // Round To Grid
    37  	opRTHG      = 0x19 // Round To Half Grid
    38  	opSMD       = 0x1a // Set Minimum Distance
    39  	opELSE      = 0x1b // ELSE clause
    40  	opJMPR      = 0x1c // JuMP Relative
    41  	opSCVTCI    = 0x1d // Set Control Value Table Cut-In
    42  	opSSWCI     = 0x1e // Set Single Width Cut-In
    43  	opSSW       = 0x1f // Set Single Width
    44  	opDUP       = 0x20 // DUPlicate top stack element
    45  	opPOP       = 0x21 // POP top stack element
    46  	opCLEAR     = 0x22 // CLEAR the stack
    47  	opSWAP      = 0x23 // SWAP the top two elements on the stack
    48  	opDEPTH     = 0x24 // DEPTH of the stack
    49  	opCINDEX    = 0x25 // Copy the INDEXed element to the top of the stack
    50  	opMINDEX    = 0x26 // Move the INDEXed element to the top of the stack
    51  	opALIGNPTS  = 0x27 // ALIGN PoinTS
    52  	op_0x28     = 0x28 // deprecated
    53  	opUTP       = 0x29 // UnTouch Point
    54  	opLOOPCALL  = 0x2a // LOOP and CALL function
    55  	opCALL      = 0x2b // CALL function
    56  	opFDEF      = 0x2c // Function DEFinition
    57  	opENDF      = 0x2d // END Function definition
    58  	opMDAP0     = 0x2e // Move Direct Absolute Point
    59  	opMDAP1     = 0x2f // .
    60  	opIUP0      = 0x30 // Interpolate Untouched Points through the outline
    61  	opIUP1      = 0x31 // .
    62  	opSHP0      = 0x32 // SHift Point using reference point
    63  	opSHP1      = 0x33 // .
    64  	opSHC0      = 0x34 // SHift Contour using reference point
    65  	opSHC1      = 0x35 // .
    66  	opSHZ0      = 0x36 // SHift Zone using reference point
    67  	opSHZ1      = 0x37 // .
    68  	opSHPIX     = 0x38 // SHift point by a PIXel amount
    69  	opIP        = 0x39 // Interpolate Point
    70  	opMSIRP0    = 0x3a // Move Stack Indirect Relative Point
    71  	opMSIRP1    = 0x3b // .
    72  	opALIGNRP   = 0x3c // ALIGN to Reference Point
    73  	opRTDG      = 0x3d // Round To Double Grid
    74  	opMIAP0     = 0x3e // Move Indirect Absolute Point
    75  	opMIAP1     = 0x3f // .
    76  	opNPUSHB    = 0x40 // PUSH N Bytes
    77  	opNPUSHW    = 0x41 // PUSH N Words
    78  	opWS        = 0x42 // Write Store
    79  	opRS        = 0x43 // Read Store
    80  	opWCVTP     = 0x44 // Write Control Value Table in Pixel units
    81  	opRCVT      = 0x45 // Read Control Value Table entry
    82  	opGC0       = 0x46 // Get Coordinate projected onto the projection vector
    83  	opGC1       = 0x47 // .
    84  	opSCFS      = 0x48 // Sets Coordinate From the Stack using projection vector and freedom vector
    85  	opMD0       = 0x49 // Measure Distance
    86  	opMD1       = 0x4a // .
    87  	opMPPEM     = 0x4b // Measure Pixels Per EM
    88  	opMPS       = 0x4c // Measure Point Size
    89  	opFLIPON    = 0x4d // set the auto FLIP Boolean to ON
    90  	opFLIPOFF   = 0x4e // set the auto FLIP Boolean to OFF
    91  	opDEBUG     = 0x4f // DEBUG call
    92  	opLT        = 0x50 // Less Than
    93  	opLTEQ      = 0x51 // Less Than or EQual
    94  	opGT        = 0x52 // Greater Than
    95  	opGTEQ      = 0x53 // Greater Than or EQual
    96  	opEQ        = 0x54 // EQual
    97  	opNEQ       = 0x55 // Not EQual
    98  	opODD       = 0x56 // ODD
    99  	opEVEN      = 0x57 // EVEN
   100  	opIF        = 0x58 // IF test
   101  	opEIF       = 0x59 // End IF
   102  	opAND       = 0x5a // logical AND
   103  	opOR        = 0x5b // logical OR
   104  	opNOT       = 0x5c // logical NOT
   105  	opDELTAP1   = 0x5d // DELTA exception P1
   106  	opSDB       = 0x5e // Set Delta Base in the graphics state
   107  	opSDS       = 0x5f // Set Delta Shift in the graphics state
   108  	opADD       = 0x60 // ADD
   109  	opSUB       = 0x61 // SUBtract
   110  	opDIV       = 0x62 // DIVide
   111  	opMUL       = 0x63 // MULtiply
   112  	opABS       = 0x64 // ABSolute value
   113  	opNEG       = 0x65 // NEGate
   114  	opFLOOR     = 0x66 // FLOOR
   115  	opCEILING   = 0x67 // CEILING
   116  	opROUND00   = 0x68 // ROUND value
   117  	opROUND01   = 0x69 // .
   118  	opROUND10   = 0x6a // .
   119  	opROUND11   = 0x6b // .
   120  	opNROUND00  = 0x6c // No ROUNDing of value
   121  	opNROUND01  = 0x6d // .
   122  	opNROUND10  = 0x6e // .
   123  	opNROUND11  = 0x6f // .
   124  	opWCVTF     = 0x70 // Write Control Value Table in Funits
   125  	opDELTAP2   = 0x71 // DELTA exception P2
   126  	opDELTAP3   = 0x72 // DELTA exception P3
   127  	opDELTAC1   = 0x73 // DELTA exception C1
   128  	opDELTAC2   = 0x74 // DELTA exception C2
   129  	opDELTAC3   = 0x75 // DELTA exception C3
   130  	opSROUND    = 0x76 // Super ROUND
   131  	opS45ROUND  = 0x77 // Super ROUND 45 degrees
   132  	opJROT      = 0x78 // Jump Relative On True
   133  	opJROF      = 0x79 // Jump Relative On False
   134  	opROFF      = 0x7a // Round OFF
   135  	op_0x7b     = 0x7b // deprecated
   136  	opRUTG      = 0x7c // Round Up To Grid
   137  	opRDTG      = 0x7d // Round Down To Grid
   138  	opSANGW     = 0x7e // Set ANGle Weight
   139  	opAA        = 0x7f // Adjust Angle
   140  	opFLIPPT    = 0x80 // FLIP PoinT
   141  	opFLIPRGON  = 0x81 // FLIP RanGe ON
   142  	opFLIPRGOFF = 0x82 // FLIP RanGe OFF
   143  	op_0x83     = 0x83 // deprecated
   144  	op_0x84     = 0x84 // deprecated
   145  	opSCANCTRL  = 0x85 // SCAN conversion ConTRoL
   146  	opSDPVTL0   = 0x86 // Set Dual Projection Vector To Line
   147  	opSDPVTL1   = 0x87 // .
   148  	opGETINFO   = 0x88 // GET INFOrmation
   149  	opIDEF      = 0x89 // Instruction DEFinition
   150  	opROLL      = 0x8a // ROLL the top three stack elements
   151  	opMAX       = 0x8b // MAXimum of top two stack elements
   152  	opMIN       = 0x8c // MINimum of top two stack elements
   153  	opSCANTYPE  = 0x8d // SCANTYPE
   154  	opINSTCTRL  = 0x8e // INSTRuction execution ConTRoL
   155  	op_0x8f     = 0x8f
   156  	op_0x90     = 0x90
   157  	op_0x91     = 0x91
   158  	op_0x92     = 0x92
   159  	op_0x93     = 0x93
   160  	op_0x94     = 0x94
   161  	op_0x95     = 0x95
   162  	op_0x96     = 0x96
   163  	op_0x97     = 0x97
   164  	op_0x98     = 0x98
   165  	op_0x99     = 0x99
   166  	op_0x9a     = 0x9a
   167  	op_0x9b     = 0x9b
   168  	op_0x9c     = 0x9c
   169  	op_0x9d     = 0x9d
   170  	op_0x9e     = 0x9e
   171  	op_0x9f     = 0x9f
   172  	op_0xa0     = 0xa0
   173  	op_0xa1     = 0xa1
   174  	op_0xa2     = 0xa2
   175  	op_0xa3     = 0xa3
   176  	op_0xa4     = 0xa4
   177  	op_0xa5     = 0xa5
   178  	op_0xa6     = 0xa6
   179  	op_0xa7     = 0xa7
   180  	op_0xa8     = 0xa8
   181  	op_0xa9     = 0xa9
   182  	op_0xaa     = 0xaa
   183  	op_0xab     = 0xab
   184  	op_0xac     = 0xac
   185  	op_0xad     = 0xad
   186  	op_0xae     = 0xae
   187  	op_0xaf     = 0xaf
   188  	opPUSHB000  = 0xb0 // PUSH Bytes
   189  	opPUSHB001  = 0xb1 // .
   190  	opPUSHB010  = 0xb2 // .
   191  	opPUSHB011  = 0xb3 // .
   192  	opPUSHB100  = 0xb4 // .
   193  	opPUSHB101  = 0xb5 // .
   194  	opPUSHB110  = 0xb6 // .
   195  	opPUSHB111  = 0xb7 // .
   196  	opPUSHW000  = 0xb8 // PUSH Words
   197  	opPUSHW001  = 0xb9 // .
   198  	opPUSHW010  = 0xba // .
   199  	opPUSHW011  = 0xbb // .
   200  	opPUSHW100  = 0xbc // .
   201  	opPUSHW101  = 0xbd // .
   202  	opPUSHW110  = 0xbe // .
   203  	opPUSHW111  = 0xbf // .
   204  	opMDRP00000 = 0xc0 // Move Direct Relative Point
   205  	opMDRP00001 = 0xc1 // .
   206  	opMDRP00010 = 0xc2 // .
   207  	opMDRP00011 = 0xc3 // .
   208  	opMDRP00100 = 0xc4 // .
   209  	opMDRP00101 = 0xc5 // .
   210  	opMDRP00110 = 0xc6 // .
   211  	opMDRP00111 = 0xc7 // .
   212  	opMDRP01000 = 0xc8 // .
   213  	opMDRP01001 = 0xc9 // .
   214  	opMDRP01010 = 0xca // .
   215  	opMDRP01011 = 0xcb // .
   216  	opMDRP01100 = 0xcc // .
   217  	opMDRP01101 = 0xcd // .
   218  	opMDRP01110 = 0xce // .
   219  	opMDRP01111 = 0xcf // .
   220  	opMDRP10000 = 0xd0 // .
   221  	opMDRP10001 = 0xd1 // .
   222  	opMDRP10010 = 0xd2 // .
   223  	opMDRP10011 = 0xd3 // .
   224  	opMDRP10100 = 0xd4 // .
   225  	opMDRP10101 = 0xd5 // .
   226  	opMDRP10110 = 0xd6 // .
   227  	opMDRP10111 = 0xd7 // .
   228  	opMDRP11000 = 0xd8 // .
   229  	opMDRP11001 = 0xd9 // .
   230  	opMDRP11010 = 0xda // .
   231  	opMDRP11011 = 0xdb // .
   232  	opMDRP11100 = 0xdc // .
   233  	opMDRP11101 = 0xdd // .
   234  	opMDRP11110 = 0xde // .
   235  	opMDRP11111 = 0xdf // .
   236  	opMIRP00000 = 0xe0 // Move Indirect Relative Point
   237  	opMIRP00001 = 0xe1 // .
   238  	opMIRP00010 = 0xe2 // .
   239  	opMIRP00011 = 0xe3 // .
   240  	opMIRP00100 = 0xe4 // .
   241  	opMIRP00101 = 0xe5 // .
   242  	opMIRP00110 = 0xe6 // .
   243  	opMIRP00111 = 0xe7 // .
   244  	opMIRP01000 = 0xe8 // .
   245  	opMIRP01001 = 0xe9 // .
   246  	opMIRP01010 = 0xea // .
   247  	opMIRP01011 = 0xeb // .
   248  	opMIRP01100 = 0xec // .
   249  	opMIRP01101 = 0xed // .
   250  	opMIRP01110 = 0xee // .
   251  	opMIRP01111 = 0xef // .
   252  	opMIRP10000 = 0xf0 // .
   253  	opMIRP10001 = 0xf1 // .
   254  	opMIRP10010 = 0xf2 // .
   255  	opMIRP10011 = 0xf3 // .
   256  	opMIRP10100 = 0xf4 // .
   257  	opMIRP10101 = 0xf5 // .
   258  	opMIRP10110 = 0xf6 // .
   259  	opMIRP10111 = 0xf7 // .
   260  	opMIRP11000 = 0xf8 // .
   261  	opMIRP11001 = 0xf9 // .
   262  	opMIRP11010 = 0xfa // .
   263  	opMIRP11011 = 0xfb // .
   264  	opMIRP11100 = 0xfc // .
   265  	opMIRP11101 = 0xfd // .
   266  	opMIRP11110 = 0xfe // .
   267  	opMIRP11111 = 0xff // .
   268  )
   269  
   270  // popCount is the number of stack elements that each opcode pops.
   271  var popCount = [256]uint8{
   272  	// 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f
   273  	0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 5, // 0x00 - 0x0f
   274  	1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, // 0x10 - 0x1f
   275  	1, 1, 0, 2, 0, 1, 1, 2, 0, 1, 2, 1, 1, 0, 1, 1, // 0x20 - 0x2f
   276  	0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 2, 2, 0, 0, 2, 2, // 0x30 - 0x3f
   277  	0, 0, 2, 1, 2, 1, 1, 1, 2, 2, 2, 0, 0, 0, 0, 0, // 0x40 - 0x4f
   278  	2, 2, 2, 2, 2, 2, 1, 1, 1, 0, 2, 2, 1, 1, 1, 1, // 0x50 - 0x5f
   279  	2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 0x6f
   280  	2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 0, 0, 0, 0, 1, 1, // 0x70 - 0x7f
   281  	0, 2, 2, 0, 0, 1, 2, 2, 1, 1, 3, 2, 2, 1, 2, 0, // 0x80 - 0x8f
   282  	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90 - 0x9f
   283  	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0 - 0xaf
   284  	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0 - 0xbf
   285  	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 - 0xcf
   286  	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 - 0xdf
   287  	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xe0 - 0xef
   288  	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xf0 - 0xff
   289  }
   290  

View as plain text