Exemple #1
0
        internal SCRIPT_ANALYSIS GetAs_SCRIPT_ANALYSIS()
        {
            SCRIPT_ANALYSIS result = default(SCRIPT_ANALYSIS);

            result.word1 = (ushort)((eScript & 0x3FF) | ((fRTL & 1) << 10) | ((fLayoutRTL & 1) << 11) | ((fLinkBefore & 1) << 12) | ((fLinkAfter & 1) << 13) | ((fLogicalOrder & 1) << 14) | ((fNoGlyphIndex & 1) << 15));
            result.state = s.GetAs_SCRIPT_STATE();
            return(result);
        }
        public SCRIPT_ANALYSIS GetAs_SCRIPT_ANALYSIS()
        {
            SCRIPT_ANALYSIS result = default(SCRIPT_ANALYSIS);

            result.word1 = (ushort)((this.eScript & 0x3FF) | (this.fRTL & 1) << 10 | (this.fLayoutRTL & 1) << 11 | (this.fLinkBefore & 1) << 12 | (this.fLinkAfter & 1) << 13 | (this.fLogicalOrder & 1) << 14 | (this.fNoGlyphIndex & 1) << 15);
            result.state = this.s.GetAs_SCRIPT_STATE();
            return(result);
        }
Exemple #3
0
        public void InitializeTruncatedCopy(ScriptRun *scriptRun, int truncatedLeadingCharsCount, int truncatedTrailingCharsCount)
        {
            this.run = scriptRun->run;
            if (this.run.RunKind == RunKind.Text)
            {
                this.run.CharCount = scriptRun->CharCount - truncatedLeadingCharsCount - truncatedTrailingCharsCount;
            }

            ScriptAnalysis       = scriptRun->ScriptAnalysis;
            CharIndexInParagraph = scriptRun->CharIndexInParagraph + truncatedLeadingCharsCount;
        }
Exemple #4
0
        public void Initialize(Run *run, SCRIPT_ANALYSIS *scriptAnalysis, int charIndexInParagraph, int charCount)
        {
            this.run = *run;
            if (this.run.RunKind == RunKind.Text)
            {
                this.run.CharCount = charCount;
            }

            CharIndexInParagraph = charIndexInParagraph;
            ScriptAnalysis       = *scriptAnalysis;
        }
Exemple #5
0
 public static extern uint ScriptPlace(
     IntPtr hdc,
     ref IntPtr psc,
     [MarshalAs(UnmanagedType.LPArray)] ushort[] pwGlyphs,
     int cGlyphs,
     [MarshalAs(UnmanagedType.LPArray)] SCRIPT_VISATTR[] psva,
     ref SCRIPT_ANALYSIS psa,
     [In, Out, MarshalAs(UnmanagedType.LPArray)] int[] piAdvance,
     [In, Out, MarshalAs(UnmanagedType.LPArray)] GOFFSET[] pGoffset,
     ref ABC pABC
     );
Exemple #6
0
 public static extern uint ScriptShape(
     IntPtr hdc,
     ref IntPtr psc,
     [MarshalAs(UnmanagedType.LPWStr)] string pwcChars,
     int cChars,
     int cMaxGlyphs,
     ref SCRIPT_ANALYSIS psa,
     [In, Out, MarshalAs(UnmanagedType.LPArray)] ushort[] pwOutGlyphs,
     [In, Out, MarshalAs(UnmanagedType.LPArray)] ushort[] pwLogClust,
     [In, Out, MarshalAs(UnmanagedType.LPArray)] SCRIPT_VISATTR[] psva,
     ref int pcGlyphs
     );
Exemple #7
0
        private int GetGlyphs(IntPtr hdc, Run run, ushort[] glyphs, int[] widths, int maxGlyphs, bool rtl)
        {
            // initialize structures
            SCRIPT_ANALYSIS psa = run.analysis;

            ushort[] pwLogClust = new ushort[maxGlyphs];
            int      pcGlyphs   = 0;

            SCRIPT_VISATTR[] psva     = new SCRIPT_VISATTR[maxGlyphs];
            GOFFSET[]        pGoffset = new GOFFSET[maxGlyphs];
            ABC pABC = new ABC();

            // make glyphs
            ScriptShape(hdc, ref FUSCache, run.text, run.text.Length, glyphs.Length, ref psa, glyphs, pwLogClust, psva, ref pcGlyphs);
            // make widths
            ScriptPlace(hdc, ref FUSCache, glyphs, pcGlyphs, psva, ref psa, widths, pGoffset, ref pABC);
            return(pcGlyphs);
        }
Exemple #8
0
        public static extern uint ScriptTextOut(
            IntPtr hdc,
            ref IntPtr psc,
            int x,
            int y,
            uint fuOptions,
//            Win32.RECT lprc,
//             IntPtr lprc,
            OptionalBase lprc,
            SCRIPT_ANALYSIS psa,
            IntPtr pwcReserved,
            int iReserved,
            [MarshalAs(UnmanagedType.LPArray)] ushort[] pwGlyphs,
            int cGlyphs,
            [MarshalAs(UnmanagedType.LPArray)] int[] piAdvance,
            [MarshalAs(UnmanagedType.LPArray)] int[] piJustify,
            [MarshalAs(UnmanagedType.LPArray)] GOFFSET[] pGoffset
            );
Exemple #9
0
 public Run(string text, SCRIPT_ANALYSIS a)
 {
     this.text     = text;
     this.analysis = a;
 }
Exemple #10
0
        public int ScriptShape(string inChars, int charPos, int length, SCRIPT_ITEM[] items, OPENTYPE_TAG[] scriptTags, int itemsCount, IntPtr hWnd, string faceName, int fontHeight, out ushort[] logClust, out SCRIPT_CHARPROP[] charProps, out ushort[] glyphs, out SCRIPT_GLYPHPROP[] glyphProps)
        {
            if (string.IsNullOrEmpty(inChars))
            {
                throw new ArgumentException("inChars");
            }
            if (items == null || items.Length <= 0)
            {
                throw new ArgumentException("items");
            }
            if (itemsCount >= items.Length)
            {
                throw new ArgumentException("itemsCount");
            }
            if (charPos < 0)
            {
                throw new ArgumentException("charPos");
            }
            if (charPos >= inChars.Length)
            {
                throw new ArgumentException("charPos");
            }
            if (length <= 0)
            {
                throw new ArgumentException("length");
            }
            if (charPos + length > inChars.Length)
            {
                throw new ArgumentOutOfRangeException("length");
            }
            if (string.IsNullOrEmpty(faceName))
            {
                throw new ArgumentException("faceName");
            }
            if (fontHeight <= 0)
            {
                throw new ArgumentException("fontHeight");
            }
            int itemIndex;

            for (itemIndex = 0; itemIndex < itemsCount - 1; itemIndex++)
            {
                if (items[itemIndex].iCharPos <= charPos)
                {
                    if (items[itemIndex + 1].iCharPos >= charPos + length)
                    {
                        break;
                    }
                }
            }
            if (itemIndex == itemsCount - 1)
            {
                if (items[itemIndex].iCharPos > charPos)
                {
                    throw new ArgumentOutOfRangeException("length");
                }
            }
            SCRIPT_ANALYSIS psa        = items[itemIndex].a;
            string          shapeChars = inChars.Substring(charPos, length);
            OPENTYPE_TAG    tagScript  = scriptTags[itemIndex];
            OPENTYPE_TAG    tagLangSys = new OPENTYPE_TAG('\0', '\0', '\0', '\0');

            int[] rangeChars = new int[]
            {
                length
            };
            logClust   = new ushort[length];
            charProps  = new SCRIPT_CHARPROP[length];
            glyphs     = new ushort[length];
            glyphProps = new SCRIPT_GLYPHPROP[length];
            for (int index = 0; index < length; index++)
            {
                glyphProps[index] = default(SCRIPT_GLYPHPROP);
                logClust[index]   = 0;
                charProps[index]  = default(SCRIPT_CHARPROP);
                glyphs[index]     = 0;
            }
            int pcGlyphs = 0;

            OPENTYPE_FEATURE_RECORD[] arRecord   = new OPENTYPE_FEATURE_RECORD[1];
            OPENTYPE_FEATURE_RECORD   potfRecord = default(OPENTYPE_FEATURE_RECORD);

            arRecord[0]           = potfRecord;
            potfRecord.tagFeature = new OPENTYPE_TAG('v', 'e', 'r', 't');
            potfRecord.lParameter = 1u;
            TEXTRANGE_PROPERTIES[] arRangeProperty = new TEXTRANGE_PROPERTIES[1];
            TEXTRANGE_PROPERTIES   rpRangeProperty = default(TEXTRANGE_PROPERTIES);

            arRangeProperty[0]          = rpRangeProperty;
            rpRangeProperty.cotfRecords = 1;
            int    cRanges     = 1;
            IntPtr arRecordPtr = Marshal.AllocHGlobal(Marshal.SizeOf(potfRecord));

            Marshal.StructureToPtr(potfRecord, arRecordPtr, false);
            IntPtr arRangePtr = Marshal.AllocHGlobal(Marshal.SizeOf(rpRangeProperty));

            rpRangeProperty.potfRecords = arRecordPtr;
            Marshal.StructureToPtr(rpRangeProperty, arRangePtr, false);
            IntPtr hDC  = User32.GetDC(hWnd);
            IntPtr font = Gdi32.CreateFontIndirect(new LOGFONT
            {
                lfCharSet  = FontCharSet.DEFAULT_CHARSET,
                lfHeight   = fontHeight,
                lfFaceName = faceName
            });
            IntPtr oldFont = Gdi32.SelectObject(hDC, font);
            int    hresult = Usp10.ScriptShapeOpenType(hDC, ref this._psc, ref psa, tagScript, tagLangSys, rangeChars, ref arRangePtr, cRanges, shapeChars, length, length, logClust, charProps, glyphs, glyphProps, ref pcGlyphs);

            Gdi32.SelectObject(hDC, oldFont);
            Gdi32.DeleteObject(font);
            User32.ReleaseDC(hWnd, hDC);
            Marshal.FreeHGlobal(arRecordPtr);
            Marshal.FreeHGlobal(arRangePtr);
            Marshal.ThrowExceptionForHR(hresult);
            return(pcGlyphs);
        }
Exemple #11
0
 public static extern uint ScriptBreak(
     [MarshalAs(UnmanagedType.LPWStr)] string pwcChars,
     int cChars,
     SCRIPT_ANALYSIS psa,
     [In, Out, MarshalAs(UnmanagedType.LPArray)] SCRIPT_LOGATTR[] psla
     );