Browse Source

Update dpf which exposes internal font

tags/v1.0
falkTX 9 years ago
parent
commit
8250ffda7b
20 changed files with 67 additions and 4004 deletions
  1. +1
    -0
      dpf/dgl/Makefile
  2. +9
    -0
      dpf/dgl/NanoVG.hpp
  3. +12
    -2
      dpf/dgl/NanoWidgets.hpp
  4. +0
    -1
      dpf/dgl/src/ImageWidgets.cpp
  5. +11
    -0
      dpf/dgl/src/NanoVG.cpp
  6. +21
    -13
      dpf/dgl/src/NanoWidgets.cpp
  7. +3
    -3
      dpf/dgl/src/Resources.cpp
  8. +3
    -3
      dpf/dgl/src/Resources.hpp
  9. +0
    -0
      dpf/dgl/src/resources/DejaVuSans.ttf
  10. +0
    -0
      dpf/dgl/src/resources/LICENSE-DejaVuSans.ttf.txt
  11. +0
    -0
      dpf/dgl/src/resources/LICENSE-blender_icons.svg.txt
  12. +0
    -0
      dpf/dgl/src/resources/blender_icons.svg
  13. +0
    -0
      dpf/dgl/src/resources/blender_icons16.png
  14. +5
    -6
      plugins/MVerb/DistrhoUIMVerb.cpp
  15. +1
    -0
      plugins/MVerb/DistrhoUIMVerb.hpp
  16. +1
    -2
      plugins/MVerb/Makefile
  17. +0
    -3964
      plugins/MVerb/font/Kh-Kangrey.cpp
  18. +0
    -9
      plugins/MVerb/font/Kh-Kangrey.h
  19. BIN
      plugins/MVerb/font/Kh-Kangrey.ttf
  20. +0
    -1
      plugins/MVerb/font/link

+ 1
- 0
dpf/dgl/Makefile View File

@@ -25,6 +25,7 @@ OBJS = \
src/ImageWidgets.cpp.o \
src/NanoVG.cpp.o \
src/NanoWidgets.cpp.o \
src/Resources.cpp.o \
src/Widget.cpp.o

ifeq ($(MACOS),true)


+ 9
- 0
dpf/dgl/NanoVG.hpp View File

@@ -20,6 +20,8 @@
#include "Color.hpp"
#include "Widget.hpp"

#define NANOVG_DEJAVU_SANS_TTF "__dpf_dejavusans_ttf__"

struct NVGcontext;
struct NVGpaint;

@@ -28,6 +30,7 @@ START_NAMESPACE_DGL
// -----------------------------------------------------------------------
// Forward class names

class BlendishWidget;
class NanoVG;

// -----------------------------------------------------------------------
@@ -841,10 +844,16 @@ public:
*/
int textBreakLines(const char* string, const char* end, float breakRowWidth, TextRow& rows, int maxRows);

/**
Load DPF's internal shared resources for this NanoVG class.
*/
virtual void loadSharedResources();

private:
NVGcontext* const fContext;
bool fInFrame;
bool fIsSubWidget;
friend class BlendishWidget;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoVG)
};


+ 12
- 2
dpf/dgl/NanoWidgets.hpp View File

@@ -18,13 +18,23 @@
#define DGL_NANO_WIDGETS_HPP_INCLUDED

#include "NanoVG.hpp"
#include "../distrho/extra/String.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class BlendishButton : public NanoWidget
class BlendishWidget : public NanoWidget
{
public:
explicit BlendishWidget(Window& parent);
explicit BlendishWidget(NanoWidget* widget);

void loadSharedResources() override;
};

// -----------------------------------------------------------------------

class BlendishButton : public BlendishWidget
{
public:
class Callback


+ 0
- 1
dpf/dgl/src/ImageWidgets.cpp View File

@@ -14,7 +14,6 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../ImageWidgets.hpp"
#include "Common.hpp"
#include "WidgetPrivateData.hpp"



+ 11
- 0
dpf/dgl/src/NanoVG.cpp View File

@@ -15,6 +15,7 @@
*/

#include "../NanoVG.hpp"
#include "Resources.hpp"
#include "WidgetPrivateData.hpp"

// -----------------------------------------------------------------------
@@ -894,6 +895,16 @@ int NanoVG::textBreakLines(const char* string, const char* end, float breakRowWi
return 0;
}

void NanoVG::loadSharedResources()
{
if (nvgFindFont(fContext, NANOVG_DEJAVU_SANS_TTF) >= 0)
return;

using namespace dpf_resources;

nvgCreateFontMem(fContext, NANOVG_DEJAVU_SANS_TTF, (const uchar*)dejavusans_ttf, dejavusans_ttf_size, 0);
}

// -----------------------------------------------------------------------

struct NanoWidget::PrivateData {


+ 21
- 13
dpf/dgl/src/NanoWidgets.cpp View File

@@ -14,27 +14,39 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../NanoWidgets.hpp"
#include "Common.hpp"
#include "Resources.hpp"

#define BLENDISH_IMPLEMENTATION
#include "nanovg/nanovg.h"
#include "oui-blendish/blendish.h"
#include "oui-blendish/blendish_resources.h"
#include "../distrho/extra/String.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

static void registerBlendishResourcesIfNeeded(NVGcontext* const context)
BlendishWidget::BlendishWidget(Window& parent)
: NanoWidget(parent)
{
if (nvgFindFont(context, "__dpf_blendish__") >= 0)
loadSharedResources();
}

BlendishWidget::BlendishWidget(NanoWidget* widget)
: NanoWidget(widget)
{
loadSharedResources();
}

void BlendishWidget::loadSharedResources()
{
if (nvgFindFont(fContext, NANOVG_DEJAVU_SANS_TTF) >= 0)
return;

using namespace blendish_resources;
using namespace dpf_resources;

bndSetFont(nvgCreateFontMem(context, "__dpf_blendish__", (const uchar*)dejavusans_ttf, dejavusans_ttf_size, 0));
bndSetIconImage(nvgCreateImageMem(context, 0, (const uchar*)blender_icons16_png, blender_icons16_png_size));
bndSetFont(nvgCreateFontMem(fContext, NANOVG_DEJAVU_SANS_TTF, (const uchar*)dejavusans_ttf, dejavusans_ttf_size, 0));
bndSetIconImage(nvgCreateImageMem(fContext, 0, (const uchar*)blender_icons16_png, blender_icons16_png_size));
}

// -----------------------------------------------------------------------
@@ -55,18 +67,16 @@ struct BlendishButton::PrivateData {
// -----------------------------------------------------------------------

BlendishButton::BlendishButton(Window& parent, const char* text, int iconId)
: NanoWidget(parent),
: BlendishWidget(parent),
pData(new PrivateData(this, text, iconId))
{
registerBlendishResourcesIfNeeded(getContext());
_updateBounds();
}

BlendishButton::BlendishButton(NanoWidget* widget, const char* text, int iconId)
: NanoWidget(widget),
: BlendishWidget(widget),
pData(new PrivateData(this, text, iconId))
{
registerBlendishResourcesIfNeeded(getContext());
_updateBounds();
}

@@ -139,6 +149,4 @@ void BlendishButton::_updateBounds()

END_NAMESPACE_DGL

#include "oui-blendish/blendish_resources.cpp"

// -----------------------------------------------------------------------

dpf/dgl/src/oui-blendish/blendish_resources.cpp → dpf/dgl/src/Resources.cpp View File

@@ -1,6 +1,6 @@
/* (Auto-generated binary data file). */
#include "blendish_resources.h"
#include "Resources.hpp"
static const unsigned char temp1[] = {137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,2,90,0,0,2,128,8,6,0,0,0,68,254,214,163,0,0,0,4,115,66,73,
84,8,8,8,8,124,8,100,136,0,0,0,9,112,72,89,115,0,0,13,215,0,0,13,215,1,66,40,155,120,0,0,0,25,116,69,88,116,83,111,
@@ -6270,7 +6270,7 @@ static const unsigned char temp1[] = {137,80,78,71,13,10,26,10,0,0,0,13,73,72,68
14,240,213,53,106,138,246,238,200,233,43,254,186,60,190,184,78,245,113,54,182,190,78,234,217,40,212,199,217,216,118,255,160,56,225,219,107,228,147,123,
169,14,167,207,238,165,186,199,187,107,215,174,20,95,114,250,210,58,138,123,235,217,232,235,84,31,167,143,44,80,117,235,217,40,212,199,233,139,103,72,
83,241,254,149,240,127,22,93,33,203,89,128,128,45,0,0,0,0,73,69,78,68,174,66,96,130,0,0};
const char* blendish_resources::blender_icons16_png = (const char*) temp1;
const char* dpf_resources::blender_icons16_png = (const char*) temp1;
static const unsigned char temp2[] = {0,1,0,0,0,19,1,0,0,4,0,48,70,70,84,77,102,9,29,176,0,0,1,60,0,0,0,28,71,68,69,70,144,48,138,184,0,0,1,88,
0,0,2,148,71,80,79,83,63,137,191,2,0,0,3,236,0,0,157,8,71,83,85,66,151,65,114,65,0,0,160,244,0,0,21,114,79,83,47,50,
@@ -24811,5 +24811,5 @@ static const unsigned char temp2[] = {0,1,0,0,0,19,1,0,0,4,0,48,70,70,84,77,102,
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,29,0,0};
const char* blendish_resources::dejavusans_ttf = (const char*) temp2;
const char* dpf_resources::dejavusans_ttf = (const char*) temp2;

dpf/dgl/src/oui-blendish/blendish_resources.h → dpf/dgl/src/Resources.hpp View File

@@ -1,9 +1,9 @@
/* (Auto-generated binary data file). */
#ifndef BINARY_BLENDISH_RESOURCES_H
#define BINARY_BLENDISH_RESOURCES_H
#ifndef BINARY_DPF_RESOURCES_HPP_INCLUDED
#define BINARY_DPF_RESOURCES_HPP_INCLUDED
namespace blendish_resources
namespace dpf_resources
{
extern const char* blender_icons16_png;
const unsigned int blender_icons16_png_size = 250706;

dpf/dgl/src/oui-blendish/resources/DejaVuSans.ttf → dpf/dgl/src/resources/DejaVuSans.ttf View File


dpf/dgl/src/oui-blendish/resources/LICENSE-DejaVuSans.ttf.txt → dpf/dgl/src/resources/LICENSE-DejaVuSans.ttf.txt View File


dpf/dgl/src/oui-blendish/resources/LICENSE-blender_icons.svg.txt → dpf/dgl/src/resources/LICENSE-blender_icons.svg.txt View File


dpf/dgl/src/oui-blendish/resources/blender_icons.svg → dpf/dgl/src/resources/blender_icons.svg View File


dpf/dgl/src/oui-blendish/resources/blender_icons16.png → dpf/dgl/src/resources/blender_icons16.png View File


+ 5
- 6
plugins/MVerb/DistrhoUIMVerb.cpp View File

@@ -19,8 +19,6 @@
#include "DistrhoUIMVerb.hpp"
#include "MVerb.h"

#include "font/Kh-Kangrey.h"

START_NAMESPACE_DISTRHO

namespace Art = DistrhoArtworkMVerb;
@@ -34,7 +32,8 @@ DistrhoUIMVerb::DistrhoUIMVerb()
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR)
{
// text
fNanoText.createFontFromMemory("kh", (const uchar*)khkangrey_ttf, khkangrey_ttfSize, false);
fNanoText.loadSharedResources();
fNanoFont = fNanoText.findFont(NANOVG_DEJAVU_SANS_TTF);

// knobs
Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight);
@@ -231,8 +230,8 @@ void DistrhoUIMVerb::onDisplay()
// text display
fNanoText.beginFrame(this);

fNanoText.fontFace("kh");
fNanoText.fontSize(20);
fNanoText.fontFaceId(fNanoFont);
fNanoText.fontSize(13);
fNanoText.textAlign(NanoVG::ALIGN_CENTER|NanoVG::ALIGN_TOP);
fNanoText.fillColor(Color(1.0f, 1.0f, 1.0f));

@@ -242,7 +241,7 @@ void DistrhoUIMVerb::onDisplay()
for (std::size_t i=0; i<MVerb<float>::NUM_PARAMS; ++i)
{
std::snprintf(strBuf, 32, "%i%%", int(fKnobs[i]->getValue()));
fNanoText.textBox(58.0f + float(fKnobs[i]->getAbsoluteX()) - 56.0f, 73.0f, 30.0f, strBuf, nullptr);
fNanoText.textBox(56.0f + float(fKnobs[i]->getAbsoluteX()) - 56.0f, 76.0f, 34.0f, strBuf, nullptr);
}

fNanoText.endFrame();


+ 1
- 0
plugins/MVerb/DistrhoUIMVerb.hpp View File

@@ -61,6 +61,7 @@ protected:
private:
Image fImgBackground;
NanoVG fNanoText;
NanoVG::FontId fNanoFont;
std::vector<ImageKnob*> fKnobs;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUIMVerb)


+ 1
- 2
plugins/MVerb/Makefile View File

@@ -17,8 +17,7 @@ OBJS_DSP = \

OBJS_UI = \
DistrhoArtworkMVerb.cpp.o \
DistrhoUIMVerb.cpp.o \
font/Kh-Kangrey.cpp.o
DistrhoUIMVerb.cpp.o

# --------------------------------------------------------------
# Do some magic


+ 0
- 3964
plugins/MVerb/font/Kh-Kangrey.cpp
File diff suppressed because it is too large
View File


+ 0
- 9
plugins/MVerb/font/Kh-Kangrey.h View File

@@ -1,9 +0,0 @@
/* binary data of Kh-Kangrey.ttf */
#ifndef BINARY_KH_KANGREY_H
#define BINARY_KH_KANGREY_H
extern const char* khkangrey_ttf;
const int khkangrey_ttfSize = 158316;
#endif

BIN
plugins/MVerb/font/Kh-Kangrey.ttf View File


+ 0
- 1
plugins/MVerb/font/link View File

@@ -1 +0,0 @@
http://openfontlibrary.org/en/font/kh-kangrey

Loading…
Cancel
Save