Generated Font Spritesheet isn't right.


This is the output of:
tb = new TextBlockRenderer(sprite, "Arial",
    SlimDX.DirectWrite.FontStretch.Normal, 12); 
The generated texture is:


(I made the background black btw)

Can anyone explain why the texture is cut-off ?

file attachments

Closed Sep 27, 2013 at 7:54 AM by Nico201


Nico201 wrote Sep 23, 2013 at 3:34 PM

Thanks for posting the issue.
Unfortunately, I cannot reproduce the problem. I just released a new version of the library which fixes some bugs in the font alignment system. Please check if the problem still occurs with the new version.
The new version also contains a sample app (in the source repository) which you can use to test some basic functionality.

wrote Sep 23, 2013 at 3:38 PM

MarijnStevens wrote Sep 24, 2013 at 8:16 PM

I couldn't open the project (not the right visual studio, I'm using VS2010 ) but after creating a new project, adding the source code, + Slimdx.dll and SpriteTextRenderer.dll I get the same result.

The only changed I made:
 Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.Debug, desc, out device, out swapChain);
 Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain);
Because for some reason I can't create it with the Debug Flag (I'm re-installing the DX SDK right now, just to be sure) but I have the same result.


Because your sample isn't working, I'm just guessing its my configuration. My video card is a NVIDIA GeForce GTX 560M.

The blending works perfectly, even thought I handled that before. Sprites also render perfectly, but the rendering of the CharTable doesn't seem to be right (on my hardware).

Could it be that my video card doesn't support non-rectangular textures (only width = height), because the texture does generate a texture of 128x256.. But I believed that was a "old" limitation.

MarijnStevens wrote Sep 24, 2013 at 8:49 PM

TL[i].Metrics.LayoutWidth and TL[i].Math.Ceiling(TL[i].Metrics.LayoutHeight is always 0.. that doesn't seem right.

Nico201 wrote Sep 24, 2013 at 10:05 PM

It's ok that LayoutWidth and LayoutHeight are both 0. That's because there is no layout rectangle provided. The necessary values can be calculated from the other values.
What OS are you running? I just found that the char table renders empty on a Windows 8.1 machine. And since the Windows 8.1 SDK is still in Preview state, I don't want to install it and thus cannot switch the device to Debug. But I doubt that this has something to do with the Debug flag. The DirectWrite, Direct2D and Direct3D10 devices are created without the debug flag.
I'll investigate this further.

MarijnStevens wrote Sep 24, 2013 at 11:54 PM

I'm running Windows 7 64 Bit (I do compile both 32 bit and 64 bit, no differents, btw: also your source code & the precompiled one )

I also do not believe it has anything to do with the Debug flag, I'm just saying I couldn't run it without changing it, (In some rare cases, it does make a differents)
System Information
Time of this report: 9/25/2013, 01:50:53
       Machine name: ----
   Operating System: Windows 7 Ultimate 64-bit (6.1, Build 7601) Service Pack 1 (7601.win7sp1_gdr.130801-1533)
           Language: English (Regional Setting: English)
System Manufacturer: CLEVO                            
       System Model: P170HMx
               BIOS: BIOS Date: 08/09/11 14:44:22 Ver: 04.06.04
          Processor: Intel(R) Core(TM) i7-2760QM CPU @ 2.40GHz (8 CPUs), ~2.4GHz
             Memory: 8192MB RAM
Available OS Memory: 8170MB RAM
          Page File: 5710MB used, 10626MB available
        Windows Dir: C:\Windows
    DirectX Version: DirectX 11
DX Setup Parameters: None
   User DPI Setting: 120 DPI (125 percent)
 System DPI Setting: 96 DPI (100 percent)
    DWM DPI Scaling: Disabled
     DxDiag Version: 6.01.7601.17514 32bit Unicode

DxDiag Notes
      Display Tab 1: No problems found.
      Display Tab 2: No problems found.
        Sound Tab 1: No problems found.
        Sound Tab 2: No problems found.
        Sound Tab 3: No problems found.
          Input Tab: No problems found.

DirectX Debug Levels
Direct3D:    4/4 (retail)
DirectDraw:  4/4 (retail)
DirectInput: 0/5 (retail)
DirectMusic: 0/5 (retail)
DirectPlay:  0/9 (retail)
DirectSound: 0/5 (retail)
DirectShow:  0/6 (retail)

Display Devices
          Card name: NVIDIA GeForce GTX 560M 
       Manufacturer: NVIDIA
          Chip type: GeForce GTX 560M
           DAC type: Integrated RAMDAC
         Device Key: Enum\PCI\VEN_10DE&DEV_1251&SUBSYS_71001558&REV_A1
     Display Memory: 4048 MB
   Dedicated Memory: 1488 MB
      Shared Memory: 2560 MB
       Current Mode: 1920 x 1080 (32 bit) (60Hz)
       Monitor Name: Generic PnP Monitor
      Monitor Model: HSD173PUW1
         Monitor Id: HSD06A5
        Native Mode: 1920 x 1080(p) (60.007Hz)
        Output Type: Internal
        Driver Name: nvd3dumx.dll,nvwgf2umx.dll,nvwgf2umx.dll,nvd3dum,nvwgf2um,nvwgf2um
Driver File Version: 9.18.0013.0697 (English)
     Driver Version:
        DDI Version: 11
       Driver Model: WDDM 1.1
  Driver Attributes: Final Retail
   Driver Date/Size: 10/3/2012 00:21:00, 18252136 bytes
        WHQL Logo'd: Yes
    WHQL Date Stamp: 
  Device Identifier: {D7B71E3E-5111-11CF-5174-0D511CC2C435}
          Vendor ID: 0x10DE
          Device ID: 0x1251
          SubSys ID: 0x71001558
        Revision ID: 0x00A1
 Driver Strong Name: oem44.inf:NVIDIA_SetA_Devices.NTamd64.6.1:Section023:\ven_10de&dev_1251&subsys_71001558
     Rank Of Driver: 00E00001

Nico201 wrote Sep 25, 2013 at 7:21 AM

It could have something to do with you scaled display:
User DPI Setting: 120 DPI (125 percent)
Could you try to change that for a moment?

MarijnStevens wrote Sep 25, 2013 at 8:56 AM

That was the problem, the resulting texture (on 96dpi):


But, while using 96dpi, the result was:


So, I've still having problem with rendering it seems.

I've hacked the source, so it can handle any DPI (I've 120 for a reason ;) )
Don't know if there is a better way for it, but it works.
public TextBlockRenderer(...) {

            float scaleX = (96.0f / D2DFactory.DesktopDpi.Width);
            float scaleY = (96.0f / D2DFactory.DesktopDpi.Height);
            rtp = new RenderTargetProperties()
                HorizontalDpi = D2DFactory.DesktopDpi.Width * scaleX,
                VerticalDpi = D2DFactory.DesktopDpi.Height * scaleY,
                Type = RenderTargetType.Hardware,
                PixelFormat = new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied),
                MinimumFeatureLevel = FeatureLevel.Direct3D10

MarijnStevens wrote Sep 25, 2013 at 8:57 AM

Darn I sound negative, but I'm not, I'm happy I can use it =D

Nico201 wrote Sep 25, 2013 at 9:22 AM

Thanks. I'll run a few test with scaled displays and the next release should be out there in a few days.

wrote Sep 27, 2013 at 7:54 AM

Aufgelöst mit Changeset 23395: Fixed DPI value for TextBlockRenderer, so it works correctly on every display setting.

wrote Sep 27, 2013 at 8:01 AM

Nico201 wrote Sep 27, 2013 at 8:01 AM

The new release is out and should resolve the problem. Here is a screenshot with 125% scaled display, Windows 8.
Thanks again for your participation.