Search in sources :

Example 1 with MockFontLayoutService

use of com.intellij.testFramework.MockFontLayoutService in project intellij-community by JetBrains.

the class AbstractEditorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    FontLayoutService.setInstance(new MockFontLayoutService(TEST_CHAR_WIDTH, TEST_LINE_HEIGHT, TEST_DESCENT));
}
Also used : MockFontLayoutService(com.intellij.testFramework.MockFontLayoutService)

Example 2 with MockFontLayoutService

use of com.intellij.testFramework.MockFontLayoutService in project intellij-community by JetBrains.

the class EditorPaintingTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    FontLayoutService.setInstance(new MockFontLayoutService(BitmapFont.CHAR_WIDTH, BitmapFont.CHAR_HEIGHT, BitmapFont.CHAR_DESCENT));
}
Also used : MockFontLayoutService(com.intellij.testFramework.MockFontLayoutService)

Example 3 with MockFontLayoutService

use of com.intellij.testFramework.MockFontLayoutService in project intellij-community by JetBrains.

the class ComplexTextFragmentTest method assertCaretPositionsForGlyphVector.

private static void assertCaretPositionsForGlyphVector(MyGlyphVector gv, int... expectedPositions) {
    FontLayoutService.setInstance(new MockFontLayoutService(TEST_CHAR_WIDTH, TEST_LINE_HEIGHT, TEST_DESCENT) {

        @NotNull
        @Override
        public GlyphVector layoutGlyphVector(@NotNull Font font, @NotNull FontRenderContext fontRenderContext, @NotNull char[] chars, int start, int end, boolean isRtl) {
            return gv;
        }
    });
    try {
        int length = gv.getNumChars();
        char[] text = new char[length];
        FontInfo fontInfo = new FontInfo(Font.MONOSPACED, 1, Font.PLAIN, false, new FontRenderContext(null, false, false));
        ComplexTextFragment fragment = new ComplexTextFragment(text, 0, length, (gv.getLayoutFlags() & GlyphVector.FLAG_RUN_RTL) != 0, fontInfo);
        int[] charPositions = new int[length];
        for (int i = 0; i < length; i++) {
            charPositions[i] = (int) fragment.visualColumnToX(0, i + 1);
        }
        assertArrayEquals(expectedPositions, charPositions);
    } finally {
        FontLayoutService.setInstance(null);
    }
}
Also used : GlyphVector(java.awt.font.GlyphVector) AbstractMockGlyphVector(com.intellij.testFramework.AbstractMockGlyphVector) MockFontLayoutService(com.intellij.testFramework.MockFontLayoutService) FontRenderContext(java.awt.font.FontRenderContext) NotNull(org.jetbrains.annotations.NotNull) FontInfo(com.intellij.openapi.editor.impl.FontInfo)

Aggregations

MockFontLayoutService (com.intellij.testFramework.MockFontLayoutService)3 FontInfo (com.intellij.openapi.editor.impl.FontInfo)1 AbstractMockGlyphVector (com.intellij.testFramework.AbstractMockGlyphVector)1 FontRenderContext (java.awt.font.FontRenderContext)1 GlyphVector (java.awt.font.GlyphVector)1 NotNull (org.jetbrains.annotations.NotNull)1