Browse Source

tags/2021-05-28
jules 18 years ago
parent
commit
e09c0ce8e6
9 changed files with 87 additions and 41 deletions
  1. +2
    -2
      build/linux/platform_specific_code/juce_linux_Fonts.cpp
  2. +5
    -1
      build/macosx/platform_specific_code/juce_mac_Fonts.cpp
  3. +1
    -3
      build/macosx/platform_specific_code/juce_mac_Windowing.cpp
  4. +12
    -0
      build/win32/platform_specific_code/juce_win32_Files.cpp
  5. +31
    -4
      build/win32/platform_specific_code/juce_win32_Fonts.cpp
  6. +31
    -4
      build/win32/platform_specific_code/juce_win32_Windowing.cpp
  7. +2
    -23
      src/juce_appframework/gui/components/keyboard/juce_KeyPress.cpp
  8. +2
    -3
      src/juce_appframework/gui/graphics/fonts/juce_Typeface.cpp
  9. +1
    -1
      src/juce_appframework/gui/graphics/fonts/juce_Typeface.h

+ 2
- 2
build/linux/platform_specific_code/juce_linux_Fonts.cpp View File

@@ -553,9 +553,9 @@ void Typeface::initialiseTypefaceCharacteristics (const String& fontName,
->createTypeface (fontName, bold, italic, *this, addAllGlyphsToFont); ->createTypeface (fontName, bold, italic, *this, addAllGlyphsToFont);
} }
void Typeface::findAndAddSystemGlyph (juce_wchar character) throw()
bool Typeface::findAndAddSystemGlyph (juce_wchar character) throw()
{ {
FreeTypeInterface::getInstance()
return FreeTypeInterface::getInstance()
->addGlyphToFont (character, getName(), isBold(), isItalic(), *this); ->addGlyphToFont (character, getName(), isBold(), isItalic(), *this);
} }


+ 5
- 1
build/macosx/platform_specific_code/juce_mac_Fonts.cpp View File

@@ -414,13 +414,14 @@ void Typeface::initialiseTypefaceCharacteristics (const String& fontName,
ATSFontHelperCache::getInstance()->releaseFont (helper); ATSFontHelperCache::getInstance()->releaseFont (helper);
} }
void Typeface::findAndAddSystemGlyph (juce_wchar character) throw()
bool Typeface::findAndAddSystemGlyph (juce_wchar character) throw()
{ {
ATSFontHelper* const helper = ATSFontHelperCache::getInstance() ATSFontHelper* const helper = ATSFontHelperCache::getInstance()
->getFont (getName(), isBold(), isItalic()); ->getFont (getName(), isBold(), isItalic());
Path path; Path path;
float width; float width;
bool foundOne = false;
if (helper->getPathAndKerning (character, T('I'), &path, width, 0, 0)) if (helper->getPathAndKerning (character, T('I'), &path, width, 0, 0))
{ {
@@ -450,9 +451,12 @@ void Typeface::findAndAddSystemGlyph (juce_wchar character) throw()
addKerningPair (g->getCharacter(), character, kerning); addKerningPair (g->getCharacter(), character, kerning);
} }
} }
foundOne = true;
} }
ATSFontHelperCache::getInstance()->releaseFont (helper); ATSFontHelperCache::getInstance()->releaseFont (helper);
return foundOne;
} }
const StringArray Font::findAllTypefaceNames() throw() const StringArray Font::findAllTypefaceNames() throw()


+ 1
- 3
build/macosx/platform_specific_code/juce_mac_Windowing.cpp View File

@@ -1070,8 +1070,6 @@ public:
} }
} }


DBG (String ((int) rawKey) + " " + String ((int) keyCode) + " " + String::charToString (textCharacter) + " " + String ((int) currentModifiers));

if ((currentModifiers & (ModifierKeys::commandModifier | ModifierKeys::ctrlModifier)) != 0) if ((currentModifiers & (ModifierKeys::commandModifier | ModifierKeys::ctrlModifier)) != 0)
textCharacter = 0; textCharacter = 0;


@@ -2824,7 +2822,7 @@ private:


if (keyPresses.size() > 0) if (keyPresses.size() > 0)
{ {
const KeyPress& kp = keyPresses.getUnchecked(0);
const KeyPress& kp = keyPresses.getReference(0);
int mods = 0; int mods = 0;


if (kp.getModifiers().isShiftDown()) if (kp.getModifiers().isShiftDown())


+ 12
- 0
build/win32/platform_specific_code/juce_win32_Files.cpp View File

@@ -44,6 +44,15 @@
#endif #endif
#include <shlobj.h> #include <shlobj.h>
#ifndef CSIDL_MYMUSIC
#define CSIDL_MYMUSIC 0x000d
#endif
#ifndef CSIDL_MYVIDEO
#define CSIDL_MYVIDEO 0x000e
#endif
BEGIN_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE
#include "../../../src/juce_core/io/files/juce_File.h" #include "../../../src/juce_core/io/files/juce_File.h"
@@ -81,6 +90,9 @@ UNICODE_FUNCTION (FindNextFileW, BOOL, (HANDLE, LPWIN32_FIND_DATAW))
void juce_initialiseUnicodeFileFunctions() throw() void juce_initialiseUnicodeFileFunctions() throw()
{ {
static_jassert (CSIDL_MYMUSIC == 0x000d);
static_jassert (CSIDL_MYVIDEO == 0x000e);
if ((SystemStats::getOperatingSystemType() & SystemStats::WindowsNT) != 0) if ((SystemStats::getOperatingSystemType() & SystemStats::WindowsNT) != 0)
{ {
HMODULE h = GetModuleHandleA ("kernel32.dll"); HMODULE h = GetModuleHandleA ("kernel32.dll");


+ 31
- 4
build/win32/platform_specific_code/juce_win32_Fonts.cpp View File

@@ -48,6 +48,7 @@ BEGIN_JUCE_NAMESPACE
UNICODE_FUNCTION (GetKerningPairsW, DWORD, (HDC, DWORD, LPKERNINGPAIR)) UNICODE_FUNCTION (GetKerningPairsW, DWORD, (HDC, DWORD, LPKERNINGPAIR))
UNICODE_FUNCTION (EnumFontFamiliesExW, int, (HDC, LPLOGFONTW, FONTENUMPROCW, LPARAM, DWORD)) UNICODE_FUNCTION (EnumFontFamiliesExW, int, (HDC, LPLOGFONTW, FONTENUMPROCW, LPARAM, DWORD))
UNICODE_FUNCTION (CreateFontIndirectW, HFONT, (CONST LOGFONTW *)); UNICODE_FUNCTION (CreateFontIndirectW, HFONT, (CONST LOGFONTW *));
UNICODE_FUNCTION (GetGlyphIndicesW, DWORD, (HDC, LPCWSTR, int, LPWORD, DWORD));
static void juce_initialiseUnicodeFileFontFunctions() static void juce_initialiseUnicodeFileFontFunctions()
{ {
@@ -65,6 +66,7 @@ BEGIN_JUCE_NAMESPACE
UNICODE_FUNCTION_LOAD (GetKerningPairsW) UNICODE_FUNCTION_LOAD (GetKerningPairsW)
UNICODE_FUNCTION_LOAD (EnumFontFamiliesExW) UNICODE_FUNCTION_LOAD (EnumFontFamiliesExW)
UNICODE_FUNCTION_LOAD (CreateFontIndirectW) UNICODE_FUNCTION_LOAD (CreateFontIndirectW)
UNICODE_FUNCTION_LOAD (GetGlyphIndicesW)
} }
} }
} }
@@ -466,7 +468,7 @@ juce_ImplementSingleton_SingleThreaded (FontDCHolder);
//============================================================================== //==============================================================================
static void addGlyphToTypeface (HDC dc,
static bool addGlyphToTypeface (HDC dc,
juce_wchar character, juce_wchar character,
Typeface& dest, Typeface& dest,
bool addKerning) bool addKerning)
@@ -478,6 +480,18 @@ static void addGlyphToTypeface (HDC dc,
BOOL ok = false; BOOL ok = false;
#if JUCE_ENABLE_WIN98_COMPATIBILITY #if JUCE_ENABLE_WIN98_COMPATIBILITY
if (wGetGlyphIndicesW != 0)
{
const WCHAR charToTest[] = { (WCHAR)character, 0 };
WORD index = 0;
if (wGetGlyphIndicesW (dc, charToTest, 1, &index, GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR
&& index < 0)
{
return false;
}
}
if (wGetTextMetricsW != 0) if (wGetTextMetricsW != 0)
{ {
TEXTMETRICW tm; TEXTMETRICW tm;
@@ -493,6 +507,17 @@ static void addGlyphToTypeface (HDC dc,
height = (float) tm.tmHeight; height = (float) tm.tmHeight;
} }
#else #else
{
const WCHAR charToTest[] = { (WCHAR)character, 0 };
WORD index = 0;
if (GetGlyphIndicesW (dc, charToTest, 1, &index, GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR
&& index < 0)
{
return false;
}
}
TEXTMETRICW tm; TEXTMETRICW tm;
ok = GetTextMetricsW (dc, &tm); ok = GetTextMetricsW (dc, &tm);
@@ -502,7 +527,7 @@ static void addGlyphToTypeface (HDC dc,
if (! ok) if (! ok)
{ {
dest.addGlyph (character, destShape, 0); dest.addGlyph (character, destShape, 0);
return;
return true;
} }
const float scaleX = 1.0f / height; const float scaleX = 1.0f / height;
@@ -620,13 +645,15 @@ static void addGlyphToTypeface (HDC dc,
} }
} }
} }
return true;
} }
//============================================================================== //==============================================================================
void Typeface::findAndAddSystemGlyph (juce_wchar character) throw()
bool Typeface::findAndAddSystemGlyph (juce_wchar character) throw()
{ {
HDC dc = FontDCHolder::getInstance()->loadFont (getName(), isBold(), isItalic(), 0); HDC dc = FontDCHolder::getInstance()->loadFont (getName(), isBold(), isItalic(), 0);
addGlyphToTypeface (dc, character, *this, true);
return addGlyphToTypeface (dc, character, *this, true);
} }
/*Image* Typeface::renderGlyphToImage (juce_wchar character, float& topLeftX, float& topLeftY) /*Image* Typeface::renderGlyphToImage (juce_wchar character, float& topLeftX, float& topLeftY)


+ 31
- 4
build/win32/platform_specific_code/juce_win32_Windowing.cpp View File

@@ -138,6 +138,7 @@ bool Desktop::canUseSemiTransparentWindows() throw()
UNICODE_FUNCTION (SetWindowTextW, BOOL, (HWND, LPCWSTR)) UNICODE_FUNCTION (SetWindowTextW, BOOL, (HWND, LPCWSTR))
UNICODE_FUNCTION (DragQueryFileW, UINT, (HDROP, UINT, LPWSTR, UINT)) UNICODE_FUNCTION (DragQueryFileW, UINT, (HDROP, UINT, LPWSTR, UINT))
UNICODE_FUNCTION (MapVirtualKeyW, UINT, (UINT, UINT)) UNICODE_FUNCTION (MapVirtualKeyW, UINT, (UINT, UINT))
UNICODE_FUNCTION (ToUnicode, int, (UINT, UINT, const PBYTE, LPWSTR, int, UINT))
UNICODE_FUNCTION (RegisterClassExW, ATOM, (CONST WNDCLASSEXW*)) UNICODE_FUNCTION (RegisterClassExW, ATOM, (CONST WNDCLASSEXW*))
UNICODE_FUNCTION (CreateWindowExW, HWND, (DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)) UNICODE_FUNCTION (CreateWindowExW, HWND, (DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID))
UNICODE_FUNCTION (DefWindowProcW, LRESULT, (HWND, UINT, WPARAM, LPARAM)) UNICODE_FUNCTION (DefWindowProcW, LRESULT, (HWND, UINT, WPARAM, LPARAM))
@@ -155,6 +156,7 @@ bool Desktop::canUseSemiTransparentWindows() throw()
HMODULE h = LoadLibraryA ("user32.dll"); HMODULE h = LoadLibraryA ("user32.dll");
UNICODE_FUNCTION_LOAD (SetWindowTextW) UNICODE_FUNCTION_LOAD (SetWindowTextW)
UNICODE_FUNCTION_LOAD (MapVirtualKeyW) UNICODE_FUNCTION_LOAD (MapVirtualKeyW)
UNICODE_FUNCTION_LOAD (ToUnicode)
UNICODE_FUNCTION_LOAD (RegisterClassExW) UNICODE_FUNCTION_LOAD (RegisterClassExW)
UNICODE_FUNCTION_LOAD (CreateWindowExW) UNICODE_FUNCTION_LOAD (CreateWindowExW)
UNICODE_FUNCTION_LOAD (DefWindowProcW) UNICODE_FUNCTION_LOAD (DefWindowProcW)
@@ -1693,7 +1695,7 @@ private:
{ {
updateKeyModifiers(); updateKeyModifiers();
const juce_wchar textChar = (juce_wchar) key;
juce_wchar textChar = (juce_wchar) key;
const int virtualScanCode = (flags >> 16) & 0xff; const int virtualScanCode = (flags >> 16) & 0xff;
if (key >= '0' && key <= '9') if (key >= '0' && key <= '9')
@@ -1723,10 +1725,35 @@ private:
// convert the scan code to an unmodified character code.. // convert the scan code to an unmodified character code..
#if JUCE_ENABLE_WIN98_COMPATIBILITY #if JUCE_ENABLE_WIN98_COMPATIBILITY
UINT keyChar = wMapVirtualKeyW != 0 ? wMapVirtualKeyW (wMapVirtualKeyW (virtualScanCode, 1), 2)
: MapVirtualKey (MapVirtualKey (virtualScanCode, 1), 2);
const UINT virtualKey = wMapVirtualKeyW != 0 ? wMapVirtualKeyW (virtualScanCode, 1)
: MapVirtualKey (virtualScanCode, 1);
UINT keyChar = wMapVirtualKeyW != 0 ? wMapVirtualKeyW (virtualKey, 2)
: MapVirtualKey (virtualKey, 2);
if (wToUnicode != 0)
{
BYTE keyState[256];
GetKeyboardState (keyState);
WCHAR unicodeChar[32];
const DWORD converted = wToUnicode (virtualKey, virtualScanCode, keyState,
unicodeChar, 32, 0);
if (converted > 0)
textChar = unicodeChar[0];
}
#else #else
UINT keyChar = MapVirtualKeyW (MapVirtualKeyW (virtualScanCode, 1), 2);
const UINT virtualKey = MapVirtualKeyW (virtualScanCode, 1);
UINT keyChar = MapVirtualKeyW (virtualKey, 2);
{
BYTE keyState[256];
GetKeyboardState (keyState);
WCHAR unicodeChar[32];
const DWORD converted = ToUnicode (virtualKey, virtualScanCode, keyState,
unicodeChar, 32, 0);
if (converted > 0)
textChar = unicodeChar[0];
}
#endif #endif
keyChar = LOWORD (keyChar); keyChar = LOWORD (keyChar);


+ 2
- 23
src/juce_appframework/gui/components/keyboard/juce_KeyPress.cpp View File

@@ -96,30 +96,9 @@ bool KeyPress::operator!= (const KeyPress& other) const throw()
bool KeyPress::isCurrentlyDown() const throw() bool KeyPress::isCurrentlyDown() const throw()
{ {
int modsMask = ModifierKeys::commandModifier
| ModifierKeys::ctrlModifier
| ModifierKeys::altModifier;
if (keyCode == KeyPress::downKey
|| keyCode == KeyPress::upKey
|| keyCode == KeyPress::leftKey
|| keyCode == KeyPress::rightKey
|| keyCode == KeyPress::deleteKey
|| keyCode == KeyPress::backspaceKey
|| keyCode == KeyPress::returnKey
|| keyCode == KeyPress::escapeKey
|| keyCode == KeyPress::homeKey
|| keyCode == KeyPress::endKey
|| keyCode == KeyPress::pageUpKey
|| keyCode == KeyPress::pageDownKey
|| (keyCode >= KeyPress::F1Key && keyCode <= KeyPress::F16Key))
{
modsMask |= ModifierKeys::shiftModifier;
}
return isKeyCurrentlyDown (keyCode) return isKeyCurrentlyDown (keyCode)
&& (ModifierKeys::getCurrentModifiers().getRawFlags() & modsMask)
== (mods.getRawFlags() & modsMask);
&& (ModifierKeys::getCurrentModifiers().getRawFlags() & ModifierKeys::allKeyboardModifiers)
== (mods.getRawFlags() & ModifierKeys::allKeyboardModifiers);
} }
//============================================================================== //==============================================================================


+ 2
- 3
src/juce_appframework/gui/graphics/fonts/juce_Typeface.cpp View File

@@ -288,10 +288,9 @@ const TypefaceGlyphInfo* Typeface::getGlyph (const juce_wchar character) throw()
return g; return g;
} }
if (! isFullyPopulated)
if ((! isFullyPopulated)
&& findAndAddSystemGlyph (character))
{ {
findAndAddSystemGlyph (character);
for (int i = 0; i < glyphs.size(); ++i) for (int i = 0; i < glyphs.size(); ++i)
{ {
const TypefaceGlyphInfo* const g = (const TypefaceGlyphInfo*) glyphs.getUnchecked(i); const TypefaceGlyphInfo* const g = (const TypefaceGlyphInfo*) glyphs.getUnchecked(i);


+ 1
- 1
src/juce_appframework/gui/graphics/fonts/juce_Typeface.h View File

@@ -295,7 +295,7 @@ private:
bool addAllGlyphsToFont) throw(); bool addAllGlyphsToFont) throw();
// platform-specific routine to look up and add a glyph to this typeface // platform-specific routine to look up and add a glyph to this typeface
void findAndAddSystemGlyph (juce_wchar character) throw();
bool findAndAddSystemGlyph (juce_wchar character) throw();
void updateHashCode() throw(); void updateHashCode() throw();
}; };


Loading…
Cancel
Save